Menu

LEN in Excel: Count Characters and Words in a Cell

=LEN(A2) returns the number of characters in A2, spaces and punctuation included. With TRIM and SUBSTITUTE it also counts words, and with SUM it counts the characters in a whole range.

Every sheet on this page is live: change a number or a formula and it recalculates.

=LEN(A2) returns the number of characters in A2. Every character counts: letters, digits, spaces, punctuation and line breaks. Hello world has 11.

Count the characters
B2
AB
1TextCharacters
2Hello world11
3 Hello world 13
4Excel5
50
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

A3 has a space at each end, so it counts 13. A5 is empty, and LEN of an empty cell is 0. The syntax has one argument: =LEN(text), where text is a cell, a formula, or text in quotes.

LEN counts the stored value, not the display

For numbers and dates, LEN counts the value Excel stores, which is not always what you see:

What LEN sees
B2
ABC
1ValueLENLEN of the display
2$1,050.0049
32026-03-15510
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

A2 shows $1,050.00 but is stored as 1050, so LEN returns 4. The date is stored as the serial number 46096, so LEN returns 5. To count the characters as displayed, convert with TEXT first, as column C does.

Count words in a cell

Excel has no word count function. Words are separated by spaces, so count the spaces and add one. TRIM first, so that double spaces and spaces at the ends are not counted as words:

Word count
B2
AB
1TextWords
2The quick brown fox4
3 two spaces 2
4one1
50
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

How it works, for The quick brown fox: the trimmed text has 19 characters; without spaces, 16. Three spaces mean four words. The IF in front makes an empty cell count 0 words instead of 1.

How many words?
B2
AB
1SentenceWords
2Payment received with thanks
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: In B2, count the words in A2. The words are separated by single spaces.

Check a character limit

LEN is how you check text against a limit: a page title of 60 characters, an SMS of 160, a product name of 30. Characters left is the limit minus LEN, and conditional formatting can flag the rows over the limit:

Titles over 30 characters
B2
ABC
1TitleCharactersLeft
2Desk lamp, black1614
3Ergonomic office chair with headrest36-6
4Monitor stand1317
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

The rule =LEN($A2)>30 colours the whole row of any title over the limit. The $ before A keeps every column of the row looking at the title. Edit A3 down to 30 characters and the colour goes away. To refuse longer text at entry, use Data > Data Validation and set Allow to Text length.

Characters left
B2
AB
1NameLeft
2Wireless mouse
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: Product names may have at most 40 characters. In B2, return how many characters are left for the name in A2.

Count characters in a range

LEN works on one cell. Give it a range inside SUM and it counts each cell, then SUM adds them:

Total characters
C2
ABC
1TextMethodTotal
2AppleSUM15
3PearSUMPRODUCT15
4Banana
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

=SUM(LEN(A2:A4)) works as it is in Excel 2021 and Microsoft 365. In Excel 2019 and older it needs Ctrl+Shift+Enter (Cmd+Shift+Enter on a Mac), or use SUMPRODUCT, which handles arrays on its own.

To count one character inside a cell, such as the commas in a list, compare the length before and after removing it: =LEN(A2)-LEN(SUBSTITUTE(A2,",","")). The SUBSTITUTE page has a live example, including how to count a whole word.

Frequently Asked Questions

How do I count characters in an Excel cell?

=LEN(A2) returns the number of characters in A2. Spaces, punctuation and line breaks all count. To ignore extra spaces, count the trimmed text: =LEN(TRIM(A2)).

How do I count words in a cell in Excel?

Count the spaces and add one: =LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2)," ",""))+1. Wrap it as =IF(TRIM(A2)="",0,...) so an empty cell counts 0 words, not 1.

Why does LEN return the wrong count for a number or a date?

LEN counts the stored value, not what the cell shows. 1,050.00isstoredas1050,soLENreturns4,andadatereturns5,thedigitsofitsserialnumber.Use‘LEN(TEXT(A2,"1,050.00 is stored as 1050, so LEN returns 4, and a date returns 5, the digits of its serial number. Use `LEN(TEXT(A2,"#,##0.00"))` to count the displayed form.

How do I count all characters in a range?

=SUM(LEN(A2:A10)) in Excel 2021 and Microsoft 365. In older versions use =SUMPRODUCT(LEN(A2:A10)), which works without Ctrl+Shift+Enter.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED