How to use RIGHT in Excel
RIGHT returns the last characters of a text — file extensions, the last digits of an account, city codes at the end of an ID.
Syntax
=RIGHT(text, [num_chars])
text | The text or cell. |
[num_chars] | How many characters (1 if omitted). |
Examples
=RIGHT(A2, 3)"BG-1024-SOF" → "SOF".=RIGHT(A2, 4)Last 4 digits of a card number.=RIGHT(A2, LEN(A2)-FIND("@", A2))Email domain after the @.The last digits of an account or card
RIGHT is the usual way to show only the end of a long number, for example on a statement or in a report shared outside the team.
="****"&RIGHT(A2, 4)A masked account: ****5678.=RIGHT(A2, 2)The last two characters, like a check digit or a year suffix.Everything after a separator
Count how many characters come after the separator: the total length minus its position.
=RIGHT(A2, LEN(A2)-FIND(" ", A2))The surname from "Anna Petrova".=RIGHT(A2, LEN(A2)-FIND("@", A2))The domain from an email address.Clean up before you cut
Trailing spaces are invisible but count as characters, so RIGHT returns the spaces instead of the digits. TRIM the text first.
=RIGHT(TRIM(A2), 4)The last four characters, ignoring spaces at the end.Common mistakes
- Trailing spaces
- "SOF " with a space returns "OF ". Clean with TRIM first.
Frequently asked questions
How do I remove the last characters of a text?
Use LEFT with the length minus the characters to drop: =LEFT(A2, LEN(A2)-2) removes the last two.
Why does RIGHT return a number as text?
RIGHT always returns text. Put -- in front to turn it into a number: =--RIGHT(A2, 4).
How do I get the text after the last space?
Replace the last space with a marker and search for it: =RIGHT(A2, LEN(A2)-FIND("#", SUBSTITUTE(A2, " ", "#", LEN(A2)-LEN(SUBSTITUTE(A2, " ", ""))))). In Microsoft 365, =TEXTAFTER(A2, " ", -1) does it in one step.
Does RIGHT work with dates?
It works on the serial number behind the date, not on what you see. Format the date first: =RIGHT(TEXT(B2, "dd.mm.yyyy"), 4) gives the year as text.
Available in: All versions of Excel, Excel for the web, Google Sheets