Learn Excel
EN

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
  1. LEN syntax
  2. Find hidden spaces
  3. Check the length
  4. Count words
  5. Count a character
  6. With LEFT and RIGHT
  7. FAQ

LEN syntax

=LEN(text)
FormulaResultWhy
=LEN("Excel")55 letters
=LEN("Anna Jansen")11The space counts too
=LEN("Mango ")6Trailing space
=LEN(A2) with 1.50 shown, 1.5 stored3LEN 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.

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, " ", "")) + 1

The 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.

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.