Excel LEN function: count the characters in a cell
LEN counts the characters in a cell: validate phone and passport numbers, find invisible spaces and count list items — step by step with examples.
LEN counts how many characters a cell contains. Everything counts: letters, digits, spaces and punctuation. It is a tiny function, yet one of the most useful tools for checking data.
Say a customer database must hold 9-digit phone numbers like 901234567. If the list came from accounting software, a Google Form or several managers, someone typed 8 digits, someone added spaces, someone added +998. LEN instantly shows which rows have the “wrong length”.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Customer | Phone | Length | |
| 2 | Aziz | 901234567 | 9 | |
| 3 | Dilnoza | 90 123 45 67 | 12 | |
| 4 | Javohir | 93123456 | 8 | |
| 5 | Malika | +998971234567 | 13 | |
| 6 | Sardor | 991234567 | 9 | |
| 7 |
Syntax
=ДЛСТР(text)
- text — the cell whose characters you want to count (
B2), text in quotes (=ДЛСТР("Tashkent")→ 8) or the result of another formula (=ДЛСТР(СЖПРОБЕЛЫ(B2))).
The result is always a whole number. An empty cell returns 0. The function has just one argument: write it once per row and fill it down.
Adding LEN — step by step
1
Select the cell for the result, for example C2.
2
On the Формулы tab click Текстовые and pick LEN from the list.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Customer | Phone | Length | |
| 2 | Aziz | 901234567 | 1 | |
| 3 | Dilnoza | 90 123 45 67 | ||
| 4 | ||||
| 5 |
3
In the Function Arguments window type B2 into the Text box (or click cell B2) and press OK. Faster: type =ДЛСТР(B2) straight into the cell and press Enter.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Customer | Phone | Length | |
| 2 | Aziz | 901234567 | 9 | |
| 3 | Dilnoza | 90 123 45 67 | ||
| 4 | ||||
| 5 |
4
Select C2 and double-click the fill handle in its bottom-right corner — the formula is copied down to the end of the list.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Customer | Phone | Length | |
| 2 | Aziz | 901234567 | 9 | |
| 3 | Dilnoza | 90 123 45 67 | 12 | |
| 4 | Javohir | 93123456 | 8 | |
| 5 | Malika | +998971234567 | 132 | |
| 6 |
Practical examples
LEN rarely works alone — it usually teams up with IF, TRIM, SUBSTITUTE or RIGHT. Below are three real tasks from simple to advanced: validating a passport number, finding invisible spaces and counting items in a list.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Full name | Passport | Check | |
| 2 | Karimov Aziz | AA1234567 | OK | |
| 3 | Rahimova Dilnoza | AB123456 | Error | |
| 4 | Toshmatov Javohir | AC 1234567 | Error | |
| 5 | Yusupova Malika | AD7654321 | OK | |
| 6 |
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Name | Length | Extra spaces | |
| 2 | Aziz | 4 | 0 | |
| 3 | Aziz | 5 | 1 | |
| 4 | Dilnoza | 8 | 1 | |
| 5 | Dilnoza | 7 | 0 | |
| 6 |
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Order | Products | Items | |
| 2 | 101 | bread, milk, yogurt | 3 | |
| 3 | 102 | rice | 1 | |
| 4 | 103 | tea, sugar | 2 | |
| 5 | 104 | flour, oil, eggs, milk | 4 | |
| 6 |
Pro level: controlling input with LEN
- Block wrong entries. Select the phone column → Данные → Проверка данных → Allow: Custom, Formula:
=ДЛСТР(B2)=9. Excel now rejects any value of a different length. - Highlight mistakes. Условное форматирование → New Rule → “Use a formula…” →
=ДЛСТР($B2)<>9— bad rows turn red automatically. - Extract the last word.
=ПРАВСИМВ(A2;ДЛСТР(A2)-НАЙТИ(" ";A2))subtracts the part up to the first space from the total length and pulls “Aziz” out of “Karimov Aziz”. - Size of a whole column.
=СУММПРОИЗВ(ДЛСТР(B2:B100))adds up every character in the column — handy for SMS or ad text limits.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Full name | First name | ||
| 2 | Karimov Aziz | Aziz | ||
| 3 | Rahimova Dilnoza | Dilnoza | ||
| 4 | Toshmatov Javohir | Javohir | ||
| 5 |
Try it in the simulator
Type =ДЛСТР(B2) in C2 and fill it down to C6. Then type =ЕСЛИ(C2=9;"OK";"Error") in D2 and fill it down as well — find the phone numbers that need fixing.
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Customer | Phone | Length | Status | ||||||||||||||||||||
| 2 | Aziz | 901234567 | ||||||||||||||||||||||
| 3 | Dilnoza | 90 123 45 67 | ||||||||||||||||||||||
| 4 | Javohir | 93123456 | ||||||||||||||||||||||
| 5 | Malika | 971234567 | ||||||||||||||||||||||
| 6 | Sardor | +998991234567 | ||||||||||||||||||||||
| 7 | ||||||||||||||||||||||||
| 8 | ||||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||
| 10 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.