fxExcelReps
PRO

You've used your 3 free functions

To practise LEN and every other function, get a PRO subscription.

  • Unlimited access to every function
  • New functions and exercises every month
  • Every mistake explained + full solutions

Your free functions — you can always come back to these:

← All functions

How to use LEN in Excel

LEN counts the characters in a text, including spaces, digits and symbols. Use it to validate codes, find extra spaces or limit text length.

Syntax

=LEN(text)

textThe text or cell.

Examples

=LEN(A2)"BG-1024-SOF" → 11.
=LEN(A2)<>LEN(TRIM(A2))TRUE if the cell has extra spaces.
=IF(LEN(B2)>160, "Too long", "OK")Check an SMS length.

Find the hidden spaces

When a lookup can't find a value you can see, compare the length with what it should be. A name with 5 letters and a length of 6 has a space somewhere.

=LEN(A2)The number of characters, spaces included.
=LEN(A2)-LEN(TRIM(A2))How many extra spaces TRIM would remove. Anything above 0 is a problem.

Check the format of IDs and codes

IDs from a core system usually have a fixed length. LEN catches the ones that lost a leading zero or got an extra character on the way.

=IF(LEN(A2)<>22, "Check IBAN", "")Flags Bulgarian IBANs that don't have 22 characters.
=COUNTIF(A2:A500, "?????")How many IDs have exactly five characters (each ? is one character).

Count words and separators

Remove the character you want to count and see how much shorter the text got.

=LEN(A2)-LEN(SUBSTITUTE(A2, ",", ""))How many commas are in A2.
=IF(TRIM(A2)="", 0, LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2), " ", ""))+1)The number of words in A2.

Common mistakes

Invisible characters
Spaces and line breaks are counted, so LEN may be larger than you expect.

Frequently asked questions

Does LEN count spaces?

Yes, every space counts, including the ones at the start and end that you can't see. That's exactly why LEN is useful for finding them.

Why does LEN show more characters than I can see?

Besides normal spaces, data from web pages and other systems can carry non-breaking spaces (CHAR(160)) or line breaks (CHAR(10)). Remove them with =SUBSTITUTE(A2, CHAR(160), "").

What does LEN return for a number?

The length of the number as Excel stores it, not as formatted. =LEN(1250.5) is 6, even if the cell shows 1,250.50.

How do I count characters in a whole range?

Use SUMPRODUCT: =SUMPRODUCT(LEN(A2:A100)). More about it in SUMPRODUCT.

Available in: All versions of Excel, Excel for the web, Google Sheets

Related functions

TRIMLEFTMIDSUBSTITUTE