Excel RIGHT Function: take characters from the end of a cell
RIGHT takes a number of characters from the end of a cell.
The formula
=RIGHT(text, [num_chars])
| Formula | A2 = “INV-2045” |
|---|---|
=RIGHT(A2,4) |
2045 |
=RIGHT(A2) |
5 (one character by default) |
Everyday uses
- Last 4 digits of an account:
="XXXX-"&RIGHT(A2,4) - File extension:
=RIGHT(A2,4)→ “.pdf” (but see below for varying lengths)
Everything after a character (length varies)
“INV-2045” and “INVOICE-7” both need the part after the dash:
=RIGHT(A2,LEN(A2)-SEARCH("-",A2))
LEN counts all characters, SEARCH finds the dash, the difference is how many are left. After the last space (surname from a full name):
=TEXTAFTER(A2," ",-1)
That one needs Excel 365. See separate first and last name.
RIGHT returns text
“2045” from RIGHT is text, so it will not add up. Wrap it: =VALUE(RIGHT(A2,4)). See VALUE.
Remove the last characters instead
That is LEFT: =LEFT(A2,LEN(A2)-3). Full lesson: remove last character.