LEN Function Excel

This Excel Tutorial demonstrates how to use the Excel LEN Function in Excel to count the number of characters, with formula examples.

LEN Function Description:

The LEN Function Counts number of characters in a text string.

Formula Examples:

len function examples

Example Formula Result
String 1 =LEN(C5) 4
String 2 =LEN(C6) 14
Leading Spaces =LEN(C7) 7

Syntax and Arguments:

The Syntax for the LEN Formula is:

Function Arguments ( Inputs ):

text – A string of text.

Additional Notes

The LEN Function is very useful when working with other text functions. Such as Left, Right, or Mid.

len1And finally, one of the more useful roles the LEN function can serve is validating a range that needs to be a specific length.

In this example a user needs to input 5 digit Zipcodes in range A2:A10. You will notice in the picture that every time a user inputs cell content that does not equal 5 characters the cell color changes, making it very easy to audit.

This is achieved by using the LEN function with conditional formatting, here’s how:

1. Select the Range or cell to apply Conditional Formatting to
2. Select Format on the Main Menu
3. Select Conditional Formatting
4. In the dropdown change Cell value is to Formula is
5. Enter =LEN(A2:A10)<>5
6. Click the Format… button and choose the format to apply if the condition is met. I changed the Pattern or background color
7. Click OK, OK

Here’s a snippet of my Conditional Formatting window using LEN


LEN Examples in VBA

You can also use the LEN function in VBA. Type:
For the function arguments (text, etc.), you can either enter them directly into the function, or define variables to use instead.

Executing the following VBA statements

will produce the following results

Vba len function


Return to the List of all Functions in Excel

How to use the LEN Function in Excel:

To use the AND Excel Worksheet Function, type the following into a cell:
After entering it in the cell, notice how the AND formula inputs appear below the cell:
len formula syntax
You will need to enter these inputs into the function. The function inputs are covered in more detail in the next section. However, if you ever need more help with the function, after typing “=LEN(” into a cell, without leaving the cell, use the shortcut CTRL + A (A for Arguments) to open the “Insert Function Dialog Box” for detailed instructions:
how to use the len function in excel

For more information about the LEN Formula visit the
Microsoft Website.