What LEN does

LEN counts the characters in a cell or a text, spaces and punctuation included. “Desk lamp, black” has 16, counting the comma and both spaces. The result is a number, so you can compare it with a limit or use it to tell LEFT, RIGHT and MID how many characters to take.

At work it checks lengths before they cause trouble, such as product titles a marketplace cuts at 40 characters or codes that must be exactly 8 long. It’s also the quickest way to find spaces you can’t see, because a name with an extra space is one character longer than it looks.

Syntax

=LEN(text)
Every argument is required.
textRequired
The text to measure, usually a cell such as A2. Every character counts: letters, digits, punctuation and spaces.

Example: which product titles are too long

A marketplace shows at most 40 characters of a title. The formula in A2 is filled down to A5, beside the titles in column B.

The standing desk title is 44 characters, 4 over the limit. In A2, =LEN(B2) returns 16.

To flag the long ones directly, put LEN inside IF: =IF(LEN(B2)>40,"Too long","OK").

Example: find the extra spaces

TRIM removes extra spaces, so the difference between the two lengths is how many extra spaces a name carries.

With its extra spaces, the first name is 14 characters long; trimmed to Ana Silva, it is 9. In B2, =LEN(A2)-LEN(TRIM(A2)) returns 5.

A non-zero result shows a name that won’t match in lookups or COUNTIF until it’s cleaned.

Count a whole column, or one character

LEN works on one text at a time. For a whole column, or for one character inside a text, combine it with another function:

  • All the characters in A2:A50: =SUMPRODUCT(LEN(A2:A50)) adds up the length of every cell, in any version of Excel. In Microsoft 365 and Excel 2021 or later, =SUM(LEN(A2:A50)) gives the same total.
  • How often one character appears in a cell: =LEN(A2)-LEN(SUBSTITUTE(A2,"-","")) counts the dashes in A2. SUBSTITUTE removes every dash, and the drop in length is how many there were. SUBSTITUTE is case-sensitive, so counting “a” this way misses “A”.

Common mistakes

  • A trailing space makes “S-118 ” six characters long. When a length is one more than you expect, look for a space at the end.
  • LEN counts the stored value, whatever the format shows. A cell showing €1,200.00 holds 1200, so =LEN(A2) is 4.
  • A date is a number underneath, so LEN measures the serial number: Mar 15, 2026 gives 5.
  • A line break typed with Alt+Enter is a character too. CLEAN removes it if it shouldn’t be there.

Frequently asked questions

Does LEN count spaces?

Yes, every space, wherever it sits in the text.

How do I count characters without spaces?

Remove the spaces first, then count: =LEN(SUBSTITUTE(A2," ","")).

How do I count the words in a cell?

Count the spaces between words and add one: =LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))+1. TRIM makes sure double spaces don’t count twice.

How do I count the characters in a whole column?

Add up the lengths with SUMPRODUCT: =SUMPRODUCT(LEN(A2:A50)) counts every character in A2:A50, spaces included. In Microsoft 365 and Excel 2021 or later, =SUM(LEN(A2:A50)) gives the same total.

Why does LEN give the wrong number?

LEN counts what the cell stores, which isn’t always what it shows. A date or a formatted price gives the length of the number underneath, and hidden spaces or line breaks add to the count.