Excel tutorial
/

Functions

Beginner

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”.

Книга1 - Excel
—☐✕
C2fx=ДЛСТР(B2)
ABCD
1CustomerPhoneLength
2Aziz9012345679
3Dilnoza90 123 45 6712
4Javohir931234568
5Malika+99897123456713
6Sardor9912345679
7
Готово
A valid number has 9 characters. 12, 8 and 13 reveal spaces, a missing digit or a +998 prefix

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.

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Вставить функциюАвтосуммаФинансовыеЛогическиеТекстовыеДата и времяСсылки и массивыМатематические
Библиотека функций
Диспетчер имён
Определённые имена
C2fx
ABCD
1CustomerPhoneLength
2Aziz9012345671
3Dilnoza90 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.

Книга1 - Excel
—☐✕
C2fx=ДЛСТР(B2)
ABCD
1CustomerPhoneLength
2Aziz9012345679
3Dilnoza90 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.

Книга1 - Excel
—☐✕
C2fx=ДЛСТР(B2)
ABCD
1CustomerPhoneLength
2Aziz9012345679
3Dilnoza90 123 45 6712
4Javohir931234568
5Malika+998971234567132
6
ГотовоСреднее: 10,5Количество: 4Сумма: 42

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.

Книга1 - Excel
—☐✕
C3fx=ЕСЛИ(ДЛСТР(B3)=9;"OK";"Error")
ABCD
1Full namePassportCheck
2Karimov AzizAA1234567OK
3Rahimova DilnozaAB123456Error
4Toshmatov JavohirAC 1234567Error
5Yusupova MalikaAD7654321OK
6
Готово
Example 1: a passport number is 2 letters + 7 digits = 9 characters. B3 is missing a digit, B4 has an extra space
Книга1 - Excel
—☐✕
C3fx=ДЛСТР(A3)-ДЛСТР(СЖПРОБЕЛЫ(A3))
ABCD
1NameLengthExtra spaces
2Aziz40
3Aziz 51
4 Dilnoza81
5Dilnoza70
6
Готово
Example 2: A2 and A3 look identical, but A3 ends with a space — that is why VLOOKUP can’t find “Aziz”
Книга1 - Excel
—☐✕
C2fx=ДЛСТР(B2)-ДЛСТР(ПОДСТАВИТЬ(B2;",";""))+1
ABCD
1OrderProductsItems
2101bread, milk, yogurt3
3102rice1
4103tea, sugar2
5104flour, oil, eggs, milk4
6
Готово
Example 3: remove the commas and compare lengths — number of commas + 1 = number of products

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.
Книга1 - Excel
—☐✕
B2fx=ПРАВСИМВ(A2;ДЛСТР(A2)-НАЙТИ(" ";A2))
ABCD
1Full nameFirst name
2Karimov AzizAziz
3Rahimova DilnozaDilnoza
4Toshmatov JavohirJavohir
5
Готово
LEN + FIND + RIGHT: “Karimov Aziz” has 12 characters, the space is 8th, so we take 12 − 8 = 4 characters from the right

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.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1CustomerPhoneLengthStatus
2Aziz901234567
3Dilnoza90 123 45 67
4Javohir93123456
5Malika971234567
6Sardor+998991234567
7
8
9
10
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

107 / 154