Excel Function Reference

RIGHT

Returns the last characters of text: the last digits of a card or phone number, the number at the end of a code.

RIGHT(text, [num_chars])
  • [ ]optional part
text
Where to take the characters from, for example cell A2.
num_chars
How many characters to take from the end. If left out, you get one.
Optional

Return value

Text: the given number of last characters. If the number is left out, the function returns one character.

Examples

Masked card number

fx
A
B
C
1
2
3
4
5
6
7
Card number
For receipt
4276 1600 3812 5678
5536 9137 0045 1209
6011 7001 6634 0981
4377 7237 4410 3356
Sheet1

Details

RIGHT takes as many characters from the end of the text as the second argument says. If it's left out, the function returns just the last character.

Spaces and symbols count too. In "4276 1600", the last four characters are "1600", and the last five are " 1600" with a space at the start.

The result is always text. Wrap the formula in VALUE to calculate with it.

Common mistakes

  • The number of characters is counted from the end: RIGHT(A2,4) returns the last four characters, not the characters starting from the fourth.
  • An invisible space at the end of the cell ends up in the result. Remove it with TRIM first.
  • A date is stored as a number, so RIGHT takes the last digits of that number, not the year. Use YEAR for the year.

See also

Where to learn