The LEN function
The number of characters in a cell, spaces included: to check a required length, or find a hidden space.
Syntax
=LEN(text)
In a French Excel: =NBCAR(texte).
Arguments
- text: the cell.
An example
=LEN(A2)<>LEN(TRIM(A2))
TRUE if A2 contains extra spaces.
Pitfalls
- A number is counted on its unformatted writing: 1234.50 counts 6 characters ("1234.5").
- Non-breaking spaces count, and TRIM does not remove them.
Going further
- Pre-import check: checks the maximum lengths of a whole column.
- LEFT, RIGHT.
Frequently asked questions
- How do I count the words in a cell?
=LEN(TRIM(A2))-LEN(SUBSTITUTE(A2," ",""))+1.