VBA Len function

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading...

The VBA Len function returns the character length of a specified string i.e. the VBA String length, assuming that the length of an empty String “” is 0.

VBA Len Syntax

The syntax for the Len function in VBA is:
function examples:

Parameters

text
The string for which the character length is to be returned for.

Example usage to get VBA String length

The Len function can be used in VBA code to get the length of VBA Strings. Let’s look at some VBA Len function examples:

Speaking to the last example it is best to use the VBA constant vbNullString instead of it’s equivalent for best performance.

Simply the best place to learn Excel VBA