To count characters in an Excel cell, use the LEN function, which returns the number of characters in a text value.
The result includes spaces and punctuation, so a quick check can reveal details that are easy to miss when reading a cell.
Count characters in one cell with LEN
Enter this formula in an empty cell, replacing A2 with the cell you want to inspect:
=LEN(A2)
If A2 contains Excel is useful, the formula returns 16: five letters in “Excel,” one space, and seven letters in “is useful.” LEN counts each space and punctuation mark as a character.
It also counts digits in text and numbers, such as the 10 digits in a numeric value displayed as 1234567890.
LEN works in current desktop versions of Excel, Excel for the web, and Excel for Mac.
It is also available in older Excel versions, so this basic formula generally does not require a recent release.
Count characters for a whole range
To count each row separately, enter =LEN(A2) in B2, then copy or fill the formula down column B.
Excel adjusts the reference for each row: B3 becomes =LEN(A3), B4 becomes =LEN(A4), and so on.
For a quick count across several cells, use a formula such as =LEN(A2)+LEN(A3)+LEN(A4).
This adds the character counts for those three cells.
It does not count characters in cells outside the listed references.
If your goal is to count every character in a range while ignoring cell boundaries, one option is to join the values and count the result.
In Microsoft 365 and Excel 2019 or later, try:
=LEN(TEXTJOIN("",TRUE,A2:A10))
TEXTJOIN combines the nonempty values in A2:A10 without adding a separator, and LEN counts the joined text.
The formula therefore counts the characters in the combined values, not spaces between cells.
If you want one space between each nonempty value, use =LEN(TEXTJOIN(" ",TRUE,A2:A10)).
That formula includes the separator spaces in the result.
TEXTJOIN is not available in some older Excel versions; use a helper column with LEN and sum its results there.
Count characters without spaces
To exclude ordinary spaces, remove them with SUBSTITUTE before counting:
=LEN(A2)-LEN(SUBSTITUTE(A2," ",""))
This formula subtracts the number of spaces from the total.
For example, if A2 contains red blue sky, LEN returns 12 and the formula returns 10.
It removes regular space characters; it does not necessarily remove tabs, nonbreaking spaces, or other whitespace characters.
Count a specific character
To count how many times a character appears in A2, subtract the length after removing that character from the original length:
=LEN(A2)-LEN(SUBSTITUTE(A2,"a",""))
If A2 contains banana, this formula returns 3 for lowercase “a.” SUBSTITUTE is case-sensitive in Excel, so the formula counts only the exact case used in the search text.
For a case-insensitive count, normalize the text and search character to the same case first.
To count a multi-character string, such as an, divide the length difference by the number of characters in the search string:
=(LEN(A2)-LEN(SUBSTITUTE(A2,"an","")))/LEN("an")
This returns the number of non-overlapping matches.
Overlapping matches need a different approach because SUBSTITUTE removes each matched occurrence before the count is calculated.
Count characters in a cell but exclude line breaks
LEN counts line breaks inside a cell.
If a value contains a line break inserted with Alt+Enter on Windows, that break contributes a character to the count.
To exclude line-feed characters, use:
=LEN(A2)-LEN(SUBSTITUTE(A2,CHAR(10),""))
Imported data may also contain carriage returns, represented by CHAR(13).
To remove both common line-break characters from the count, use:
=LEN(SUBSTITUTE(SUBSTITUTE(A2,CHAR(10),""),CHAR(13),""))
This counts all remaining characters, including spaces and punctuation.
If data contains other control characters, identify and remove those separately.
Why might LEN return an unexpected count?
- Leading or trailing spaces: LEN includes them even when they are difficult to see.
Use=LEN(TRIM(A2))to count after removing leading and trailing regular spaces and reducing repeated internal spaces to one.
TRIM does not remove every type of whitespace. - Formulas that return text: LEN counts the displayed text value produced by the formula, not the formula’s characters.
For example, if A2 contains=1+2, LEN counts the result3as one character. - Number formatting: LEN generally counts the underlying value converted to text, not every symbol added by cell formatting.
A date displayed asNovember 3, 2026may have a shorter underlying date value.
To count a specific formatted representation, convert it explicitly with TEXT, as in=LEN(TEXT(A2,"mm/dd/yyyy")). - Blank cells: LEN of an empty cell returns 0.
A cell containing a formula that returns an empty string,"", also produces a count of 0. - Unicode characters: Some visible symbols, emoji, or accented characters can be represented by multiple code units.
In newer Microsoft 365 versions, LEN may count certain compatibility characters as one character; in older versions, counts can differ.
Check the result in the Excel version used by your audience when exact character limits matter.
Use character counts for data checks
LEN can help enforce input limits, find accidental spaces, and review imported data.
To flag values in A2 that exceed a 50-character limit, use:
=IF(LEN(A2)>50,"Too long","OK")
To count a full column’s total characters, create per-row counts in B2:B100 with =LEN(A2) filled down, then add them with =SUM(B2:B100).
This method makes the individual counts visible and easy to audit.
If your worksheet uses semicolons as formula argument separators, replace commas with semicolons in formulas such as the IF example.