Excel Text Length Formula: How to Count Characters
In this article
The Excel TEXT LENGTH formula, using the LEN function, counts the total number of characters in a cell, including spaces and punctuation. It’s essential for data validation, cleaning text entries, or preparing inputs for other functions. No add-ins or special settings are required — this works in all modern versions of Excel, including Excel for Microsoft 365, Excel 2021, Excel 2019, and earlier versions from 2007 onward.
What You'll Need
- A cell containing text you want to measure
- Another blank cell to display the result
- Microsoft Excel installed (any version from 2007 or later)
Step-by-Step
- Open your Excel workbook and locate the cell with the text you want to count. For example, suppose cell A2 contains the phrase "Hello World".
- Click on a different blank cell where you want the character count to appear — for instance, cell B2.
- Type the formula:
=LEN(A2). Do not include the quotes. Ensure the cell reference matches the location of your text. - Press Enter. The result will appear in the cell — in this case, 11, because "Hello World" has 11 characters including the space.
- To apply this to multiple rows, click on the cell with the formula (B2), then move your cursor to the bottom-right corner until it turns into a small black cross (the fill handle).
- Click and drag the fill handle down over the adjacent cells in column B that correspond to text in column A. Excel will automatically update the references (e.g., A3, A4, etc.) and calculate the length for each row.
- If your text spans multiple cells and you want to count them together, use a formula like
=LEN(A2&B2)to concatenate before counting. For example, if A2 is "John" and B2 is "Doe", the result will be 7.
Common Mistakes
- Typing
LENwithout parentheses — Excel will return an error. Always use=LEN(cell), not=LEN cell. - Referencing an empty cell — LEN returns 0 for blank cells, which may be misleading if you expect text to be present. Always verify the source cell isn’t truly empty.
- Forgetting that spaces count — many assume only letters and numbers matter, but a single space adds one to the count. If you need to exclude spaces, use
=LEN(SUBSTITUTE(A2," ","")). - Using text formatted as numbers — if a cell contains "123" but is formatted as a number, LEN still returns 3. Excel treats it as text for counting purposes.
- Trying to count characters across multiple non-contiguous cells without concatenation —
=LEN(A2,A3)is invalid syntax. Use=LEN(A2&A3)or add multiple LEN functions:=LEN(A2)+LEN(A3).
Tips
- Combine LEN with TRIM to remove extra leading/trailing spaces before counting:
=LEN(TRIM(A2)). This helps clean messy imported data. - Use LEN with IF statements to flag unusually long entries:
=IF(LEN(A2)>50,"Too long","OK"). Useful for form validation. - When checking for duplicates based on length, pair LEN with COUNTIF:
=COUNTIF($B$2:$B$100,B2)where column B contains LEN results. - For Unicode or non-English characters (like accented letters or emojis), LEN counts each symbol as one character — even if it displays as two visual glyphs.
- Use F4 to toggle between relative, absolute, and mixed references when dragging formulas — press it after typing A2 to make it $A$2 if you need the reference locked.
Troubleshooting
- If you see #NAME? — Excel doesn’t recognize LEN. Check for typos like "LNE" or "Len". Function names are case-insensitive, but spelling must be exact.
- If the result is 0 but the cell appears to have text — check for hidden characters. Copy the cell and paste into Notepad to see if spaces or line breaks exist. Use
=LEN(SUBSTITUTE(A2,CHAR(160),""))if non-breaking spaces (common from web copy) are the issue. - If dragging the formula doesn’t update — ensure the cells below are not merged or protected. Also verify that AutoFill is enabled: go to File > Options > Advanced > Editing Options and check "Enable fill handle and cell drag-and-drop".
- If the formula shows as text instead of a result — the cell is formatted as Text. Right-click the cell, choose Format Cells, and change to General or Number.
- If you’re using Excel Online and the formula doesn’t work — refresh the page. Occasionally, Excel Online has caching delays. Re-enter the formula manually.
Frequently Asked Questions
Does LEN count spaces in Excel?
Yes, LEN counts every character, including spaces, tabs, line breaks, and punctuation. "A B" returns 3, not 2.
Can I count characters in multiple cells at once?
Not directly with one LEN function. Add multiple LEN results: =LEN(A1)+LEN(A2)+LEN(A3). Alternatively, concatenate first: =LEN(A1&A2&A3).
Why does LEN return 1 for a cell showing "0"?
Because Excel treats "0" as text in that context. Even if formatted as a number, if it was entered as text (e.g., preceded by an apostrophe), LEN counts it as one character.
Does LEN work with dates and times?
Yes, but it counts the underlying serial number as text. A date like 1/1/2024 may return 8 because Excel stores it as a number (e.g., 45309) and displays it formatted. Use =LEN(TEXT(A2,"mm/dd/yyyy")) to count the displayed format instead.
How do I exclude spaces from the count?
Use =LEN(SUBSTITUTE(A2," ","")). This replaces all spaces with nothing before counting, effectively removing them from the total.
Can I use LEN to find the longest text in a column?
Yes. Use =MAX(LEN(A2:A100)) as an array formula (Ctrl+Shift+Enter in older Excel versions). In Excel 365, just press Enter. Then use MATCH to find which row it appears in.