What is VBA LEN Function
how to use it
To use VBA's LEN function you need to understand its syntax and arguments:
- Expression: The expression for which you want to count the characters.
Example to use LEN Function in VBA
To practically understand how to use VBA LEN function, you need to go through the below example where we have written a vba code by using it:
Sub example_LEN() Range("B1").Value = Len(Range("A1")) End Sub
In the above code, we have used the LEN to count the number of characters from the cell A1 (Excel Champs) and in the result, it has returned 12 in the result as the value “Excel Champs” has 12 characters including the space between the words.
Below are some important points which you need to take care while using LEN function in VBA.
- If the supplied string is NULL it will return NULL in the result.
About the Author
Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.