Learn Excel
EN
Sets how numbers, dates and formulas look, so everything works just like your own Excel.

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. Try it yourself
  4. Check the length
  5. Count words
  6. Count a character
  7. With LEFT and RIGHT
  8. In practice: check product titles against a character limit
  9. Keep learning
  10. 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.

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

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:

ABC
1Product titleLengthCheck
2Wireless mouse, black21OK
3Ergonomic office chair with adjustable armrests47Too long
4USB-C charger 65W17OK
  • 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.

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.