The LEN function
LEN tells you how many characters a cell holds. Every letter, digit, space and symbol counts as one.
On its own it's a quick way to find codes that are too long or too short, or cells with hidden spaces. Combined with LEFT, RIGHT and MID, it lets you work out how much text to take.
=LEN(text)
Arguments
- text
- The text (or cell) whose characters you want to count. Spaces and punctuation count too.
Try it
=LEN(A2) in B2. LS1 4DY has six letters and digits plus one space, so LEN returns 7.
B2
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Postcode | Length | ||
| 2 | LS1 4DY | 7 | ||
| 3 | M1 1AE | |||
| 4 | BS8 1TH | |||
| 5 | EH1 2NG | |||
| 6 | ||||
| 7 |
Edit the formula in B2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =LEN(A4) | 8 | BS8 1TH looks like 7 characters, but a trailing space makes it 8. |
| =LEN(TRIM(A4)) | 7 | TRIM removes the stray space before counting. |
| =LEN(SUBSTITUTE(A2," ","")) | 6 | Count the characters without spaces by removing them first. |
| =LEN(A3) | 6 | Shorter postcodes give a smaller count, so LEN alone can't check a postcode's format. |
Tips
- Count how many times a character appears:
=LEN(A2)-LEN(SUBSTITUTE(A2," ",""))counts the spaces. - Use LEN in a filter or conditional format to flag codes that aren't the expected length.
=RIGHT(A2,LEN(A2)-4)drops the first four characters of any text.
Common mistakes
- Two cells look identical but LEN gives different counts.One has extra spaces at the start or end. Clean them with TRIM.
- LEN on a date returns 5.Dates are stored as serial numbers like 45730, so LEN counts those digits. Use TEXT to format the date first if you need the shown length.
- LEN of an amount shown as £12.50 returns 4, not 6.LEN counts the stored value (12.5), not the currency format.
Practise LEN with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.