What is the LEN function?
=LEN(text)LEN counts the characters in a text. It is often used to check input length or to work out character counts for other text functions.
Spaces count as characters. Invisible spaces at the start or end make LEN larger than expected, so check with LEN first when data looks odd.
Arguments
- text
- The text or cell whose characters you count. For a number, it counts the digits.
LEN examples
Example 1. Length of a city name
=LEN("New York City")11 letters and 2 spaces: 13.
Example 2. A blank cell
=LEN(A2)If A2 is empty, 0.
Example 3. How many extra spaces
=LEN(A2)-LEN(TRIM(A2))The number of spaces TRIM would remove.
Common mistakes
Counting number formatting
A number shown as 1,000 is stored as 1000, so LEN returns 4.
Expecting double-byte characters to count as 2
LEN counts every character as 1. LENB counts bytes instead.
FAQ
- Are line breaks counted?
- A line break inside a cell (Alt+Enter) counts as one character.
- How often does a character appear?
- Subtract the length without it: =LEN(A2)-LEN(SUBSTITUTE(A2,"-","")).