# VBA LEN Function

Home ➜ VBA Functions LIST (Category Wise) ➜ **How to use the VBA LEN Function (Syntax + Example)**

## What is VBA LEN Function

The VBA LEN function is listed under the text category of VBA functions. When you use it in a VBA code, **it returns the number of characters in a string**. In simple words, you can count the number of characters of a string. It works like the LEN function in the worksheet.

## how to use it

To use VBA's LEN function you need to understand its syntax and arguments:

### Syntax

**Len(Expression)**

### 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.

## Notes

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.

## Related Functions

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.