Description
Use this function to determine the length of a text string by counting the number of characters it contains. Supported in Chains.
LEN is useful for text analysis, data validation, and in combination with other text functions.
Syntax
LEN(text)
Inputs
This function accepts the following argument:
| Name | Required | Description | Valid input |
|---|---|---|---|
text |
Yes | The text whose length you want to find. | A text string, a reference to a cell containing text, or a formula that returns text. |
Example
Sample data
| A | B |
|---|---|
| 1 | Hello, World! |
| 2 | Excel |
| 3 | 123 |
| 4 | Space |
Sample formulas
| Formula | Description | Result |
|---|---|---|
=LEN(B1) |
Counts the number of characters in "Hello, World!" | 13 |
=LEN(B2) |
Counts the number of characters in "Excel" | 5 |
=LEN(B3) |
Counts the number of characters in "123" (stored as text) | 3 |
=LEN(B4) |
Counts the number of characters in " Space " including spaces | 7 |
=LEN("") |
Counts the number of characters in an empty string | 0 |
Notes
- LEN counts all characters, including spaces and special characters.
- When used with a number, LEN first converts the number to text, then counts the characters.
- LEN does not count the characters in the cell formatting.
- For empty cells, LEN returns 0.
- LEN treats each cell in a range separately; it doesn't sum the lengths of multiple cells.
Tips
- Use LEN in combination with LEFT, RIGHT, or MID to extract portions of text based on their length.
- Combine LEN with TRIM to count characters excluding leading and trailing spaces.
- Use LEN for data validation, e.g., to ensure a code or ID is the correct length.
- In array formulas, LEN can be used to process multiple cells at once.
- Remember that LEN counts Unicode characters, so some special characters or symbols may be counted as more than one character.
Related functions
CHAR
CODE
CONCATENATE
CONCATENATEIF
FIND
LEFT
LEN
LOWER
MID
PROPER
REPT
RIGHT
SEARCH
SUBSTITUTE
TEXT
TEXTJOIN
TRIM
UNICHAR
UNICODE
UPPER