Excel tutorial
/

Functions

Beginner

How to use RIGHT in Excel: extract characters from the end of text

RIGHT takes characters from the end of text: the last 4 card digits, a document number, a first name. Pairing with LEN and FIND, plus number traps.

RIGHT is LEFT’s mirror image: it takes the number of characters you need from the right side — the end — of a text.

Where it helps:

  • The last 4 digits of a bank card — so the full number isn’t shown in a report.
  • The sequence number from an invoice “INV-2025-0147” — 0147.
  • The first name from “Karimov Aziz” — Aziz (RIGHT + LEN + FIND).
  • The extension from a file name: “report.xlsx” → xlsx.
Книга1 - Excel
—☐✕
C2fx=ПРАВСИМВ(B2;4)
ABCD
1ClientCard numberLast 4
2Aziz8600 1234 5678 9012190122
3Dilnoza9860 0101 2345 67896789
4Javohir8600 5555 4444 32103210
5Malika9860 1200 9876 04510451
6
Готово
=RIGHT(B2,4) — the last 4 characters of the card number (1): 9012 (2)

Syntax

=ПРАВСИМВ(text; [num_chars])

  • text — the text or a cell containing text.
  • num_chars — how many characters to take from the end. If omitted — 1. Longer than the text — the whole text. Negative — #VALUE!.

Just like LEFT: a space is a character too, and the result is always text. That’s exactly why the leading zero in “0147” survives.

Writing RIGHT step by step

1

Select C2: Формулы → Текстовые → RIGHT.

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Вставить функциюАвтосуммаФинансовыеЛогическиеТекстовыеДата и времяСсылки и массивыМатематические
Библиотека функций
Диспетчер имён
Определённые имена
C2fx
ABCD
1ClientCard numberLast 4
2Aziz8600 1234 5678 9012
3Dilnoza9860 0101 2345 6789
4Javohir8600 5555 4444 3210
5
Готово

2

Text — B2, Num_chars — 4. Click OK and fill the formula down.

Книга1 - Excel
—☐✕
C2fx
ABCD
1ClientCard numberLast 4
2Aziz8600 1234 5678 9012
3Dilnoza9860 0101 2345 6789
4Javohir8600 5555 4444 3210
5Malika9860 1200 9876 0451
6
Готово

3

Now build a “masked” number: type ="**** "&ПРАВСИМВ(B2;4) in D2. & joins text together — the full card number never appears in a report sent to the client.

Книга1 - Excel
—☐✕
D2fx="**** "&ПРАВСИМВ(B2;4)
ABCDE
1ClientCard numberLast 4For report
2Aziz8600 1234 5678 90129012**** 9012
3Dilnoza9860 0101 2345 67896789**** 6789
4Javohir8600 5555 4444 32103210**** 3210
5Malika9860 1200 9876 04510451**** 0451
6
ГотовоКоличество: 4

Example: extracting the first name — RIGHT + LEN + FIND

You need first names from a “Surname Name” list. Names vary in length, so we calculate how many characters are needed:

=ПРАВСИМВ(A2;ДЛСТР(A2)-НАЙТИ(" ";A2))

  • LEN(A2) — the length of the whole text: “Karimov Aziz” is 12.
  • FIND(" ",A2) — the position of the space: 8.
  • 12 − 8 = 4 — the number of characters after the space. RIGHT takes the last 4: “Aziz”.
Книга1 - Excel
—☐✕
D2fx=ПРАВСИМВ(A2;B2-C2)
ABCDE
1Full nameLENSpace atFirst name
2Karimov Aziz128Aziz
3Rahimova Dilnoza169Dilnoza
4Tursunov Javohir169Javohir
5Yusupova Malika159Malika
6
Готово
The helper columns show the arithmetic: 12 − 8 = 4 characters. As one formula: =RIGHT(A2,LEN(A2)-FIND(" ",A2))

Example: turning a document number into a number

Invoices look like “INV-2025-0147”. =ПРАВСИМВ(A2;4) gives “0147”, but that is text: SUM and MAX ignore it (MAX returns 0), and comparisons with numbers go wrong.

If you need a number, wrap it in VALUE: =ЗНАЧЕН(ПРАВСИМВ(A2;4)) → 147. Look at the alignment: text sits on the left, numbers on the right.

Книга1 - Excel
—☐✕
C5fx=МАКС(C2:C4)
ABCD
1InvoiceRIGHT (text)VALUE (number)
2INV-2025-01470147147
3INV-2025-01520152152
4INV-2025-120012001200
5Largest:01200
6
Готово
MAX ignores text and gives 0. With the numbers converted by VALUE — 1200

Pro level: the part after the last delimiter

When codes have different numbers of parts (“UZ-SAM-12”, “UZ-TSH-CHL-0147”), FIND can’t locate the last hyphen — it finds the first one. The classic trick:

=СЖПРОБЕЛЫ(ПРАВСИМВ(ПОДСТАВИТЬ(A2;"-";ПОВТОР(" ";50));50))

  1. SUBSTITUTE replaces every hyphen with 50 spaces.
  2. RIGHT(…,50) takes the last 50 characters — only spaces and the last part are in there.
  3. TRIM removes the spaces.

In Excel 365 it is much simpler: =ТЕКСТПОСЛЕ(A2;"-";-1) (-1 means the first delimiter from the end).

Книга1 - Excel
—☐✕
B2fx=СЖПРОБЕЛЫ(ПРАВСИМВ(ПОДСТАВИТЬ(A2;"-";ПОВТОР(" ";50));50))
ABCD
1CodeLast part
2UZ-TSH-CHL-01470147
3UZ-SAM-1212
4UZ-BUX-GJD-A-55905590
5
Готово
The number of parts varies, yet the formula always returns the part after the last hyphen

Try it in the simulator

Type ="**** "&ПРАВСИМВ(B2;4) in C2 and fill it down to C5 to mask the cards. Then type =ПРАВСИМВ(A2;ДЛСТР(A2)-НАЙТИ(" ";A2)) in D2 to extract the first names.

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1Full nameCard numberFor reportFirst name
2Karimov Aziz8600 1234 5678 9012
3Rahimova Dilnoza9860 0101 2345 6789
4Tursunov Javohir8600 5555 4444 3210
5Yusupova Malika9860 1200 9876 0451
6
7
8
9
10
Лист1
Готово

Has ExcelLab been useful?

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

Support us
Previous

105 / 154