
Returns the number of characters in a text string, including spaces.
The Excel LEN function returns the number of characters in a text string. It counts letters, numbers, spaces, punctuation, and other characters that appear in the value. If the cell is empty, LEN returns 0.
LEN is often used for checks and validation. You can use it to confirm that an ID has the right length, to detect hidden spaces, or to measure whether a value is empty. Even when two cells look the same on screen, LEN can reveal extra characters that affect formulas and lookups.
Returns how many characters are in the text, including spaces.
Returns a numeric count such as 5, 10, or 0.
=LEN(text)
LEN takes one argument: the text or cell you want to count. You can pass a cell reference like =LEN(A1) or typed text like =LEN("hello").
LEN counts characters, but it is often paired with cleaning functions when you want to check the quality of imported text. TRIM removes extra spaces, CLEAN removes some non-printing characters, and SUBSTITUTE can remove one chosen character so LEN can compare before and after.
| Function | Main Role | Use When |
|---|---|---|
LEN |
Count characters | You want to measure the length of a value |
TRIM |
Remove extra spaces | You want to compare length before and after cleaning spaces |
CLEAN |
Remove non-printing characters | You suspect hidden control characters in imported text |
SUBSTITUTE |
Replace chosen text | You want to count how many times a specific character appears |
A common pattern is =LEN(A1)-LEN(SUBSTITUTE(A1,",","")). The formula removes commas, counts the new length, and subtracts it from the original length. The difference tells you how many commas were in the original text.
LEN is helpful when the length itself has meaning. If an ID must be exactly 8 characters, LEN can check every row quickly. If a field looks blank but still causes problems in a formula, LEN can show whether there is actually a space or another character inside it.
LEN is also useful before and after cleanup. For example, if LEN(A1) is different from LEN(TRIM(A1)), then the cell contains extra spaces. That makes LEN a simple audit tool for imported text.
This is the direct use of LEN. Excel counts every character in the string, including spaces. That makes LEN useful when the exact size of a value matters.
=LEN("ExcelClash") // 10
=LEN("A B") // 3
=LEN("") // 0
In cell F1, use LEN to count the characters in "ExcelClash". Expected result: 10.
LEN works well inside IF for simple format checks. If the ID length matches the expected value, the formula returns "OK". Otherwise it returns an error message.
=IF(LEN(C3)=5, "OK", "Format Error")
// C3="12345" -> "OK"
// C3="1234" -> "Format Error"
In cell F2, check if C3 is exactly 5 characters long. Formula: =IF(LEN(C3)=5,"OK","Format Error").
This is one of the most practical LEN checks. If a value contains a trailing space, LEN counts it even though it is hard to notice on screen. Comparing the original text with the trimmed version shows how many extra spaces were present.
=LEN(A1) // "Alpha " -> 6
=LEN(TRIM(A1)) // "Alpha" -> 5
=LEN(A1)-LEN(TRIM(A1)) // 1
In cell F3, compare the length of A1 with and without TRIM. Formula: =LEN(A1)-LEN(TRIM(A1)).
A blank cell returns 0, so LEN can also be used as a basic emptiness check. That is useful in input forms, required-field checks, and simple data audits.
=LEN(B2) // 0
=IF(LEN(B2)=0,"Required","Filled")
In cell F4, use LEN on the empty cell B2. Expected result: 0.
LEN counts the underlying text form of a value. If a number or date is displayed with a custom format, LEN does not count the visible formatting unless you first convert the value with TEXT.
LEN counts the characters in a value.=LEN(text).Tell your friends about this post