Home › Excel functions › LEN
LEN Function in Excel: Count Characters and Words
LEN returns the number of characters in a cell, including spaces. Simple on its own, but it's the key to spotting invisible spaces, validating codes and counting words.
In this guide
LEN syntax
=LEN(text)| Formula | Result | Why |
|---|---|---|
=LEN("Excel") | 5 | 5 letters |
=LEN("Anna Jansen") | 11 | The space counts too |
=LEN("Mango ") | 6 | Trailing space |
=LEN(A2) with 1.50 shown, 1.5 stored | 3 | LEN counts the value, not the formatting |
Find hidden spaces
When a lookup returns #N/A for a value that looks correct, compare its length with the trimmed version:
=LEN(A2) <> LEN(TRIM(A2))TRUE means there are extra spaces. Clean them with TRIM.
LEN practice: try it yourself
Reading is one thing, typing it is another. Build the formula below step by step: the tips tell you what to type next, and you can click or drag across cells to add them, just like in Excel.
Task: Count the characters in the product code, in B2: =LEN(A2)
Check codes have the right length
Postal codes, IBANs and product codes usually have a fixed length. Flag the wrong ones:
=IF(LEN(A2)<>6, "Check", "")You can also enforce it on input: Data › Data Validation › Allow: Text length › equal to 6.
Count words in a cell
=LEN(TRIM(A2)) - LEN(SUBSTITUTE(A2, " ", "")) + 1The number of spaces plus one is the number of words. "The quick brown fox" returns 4. TRIM makes sure double spaces don't inflate the count. For an empty cell this returns 1; wrap it if needed: =IF(A2="", 0, …).
Count a specific character
=LEN(A2) - LEN(SUBSTITUTE(A2, "@", ""))How many @ signs are in the cell. Useful to check if a cell contains more than one email address. See SUBSTITUTE.
With LEFT, RIGHT and MID
LEN tells you how much text there is, which helps when removing characters:
- Remove the first 3 characters:
=RIGHT(A2, LEN(A2)-3) - Remove the last 2 characters:
=LEFT(A2, LEN(A2)-2)
More in LEFT, RIGHT and MID.
In practice: check product titles against a character limit
A marketplace accepts product titles of at most 40 characters. Before uploading, LEN shows which titles need to be shorter:
| A | B | C | |
|---|---|---|---|
| 1 | Product title | Length | Check |
| 2 | Wireless mouse, black | 21 | OK |
| 3 | Ergonomic office chair with adjustable armrests | 47 | Too long |
| 4 | USB-C charger 65W | 17 | OK |
- B2:
=LEN(A2) - C2:
=IF(LEN(A2)>40, "Too long", "OK")
Spaces count as characters too. Add a column with =40-LEN(A2) and you see straight away how many characters are left, or how many need to go.
Keep learning
Frequently asked questions
Does LEN count spaces?
Yes, every space counts as a character, including leading and trailing spaces.
Can LEN count characters in a range?
Yes, with SUM: =SUM(LEN(A2:A10)) in Microsoft 365, or =SUMPRODUCT(LEN(A2:A10)) in older versions.
Why does LEN return a different number than I see?
The cell contains hidden characters (spaces, line breaks) or the displayed number is formatted differently from the stored value.