The RIGHT function
RIGHT takes characters from the end of some text: the sequence number on an invoice reference, the last digits of a phone number, or a file extension.
It counts backwards from the last character. For an end piece of varying length, combine it with LEN and FIND.
=RIGHT(text, [num_chars])
Arguments
- text
- The text (or cell) to take characters from.
- num_charsoptional
- How many characters to take from the end. Leave it out to take just one.
Try it
=RIGHT(A2,4) in C2. The last four characters of INV-2025-0047 are 0047, the invoice's sequence number.
C2
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Invoice | Mobile | Number | |
| 2 | INV-2025-0047 | 07700 900123 | 0047 | |
| 3 | INV-2025-0112 | 07700 900588 | ||
| 4 | CRN-2024-0009 | 07700 900314 | ||
| 5 | ||||
| 6 |
Edit the formula in C2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =RIGHT(B2,3) | 123 | The last three digits of the mobile number, for example to show a masked number. |
| =RIGHT(A4,LEN(A4)-FIND("-",A4)) | 2024-0009 | Everything after the first dash: the total length minus the dash's position. |
| =RIGHT(A3) | 2 | With no count, RIGHT returns just the last character. |
Tips
LEN(A2)-FIND("-",A2)gives the number of characters after the first dash, which makes RIGHT work on references of any length.- Masking a card or phone number? Join a fixed prefix to RIGHT:
="*** "&RIGHT(B2,3). - In Excel 365,
TEXTAFTERis often simpler than RIGHT with LEN and FIND. Google Sheets doesn't have it.
Common mistakes
- RIGHT returns spaces or seems to miss the last characters.The cell probably ends with spaces you can't see. Use
=RIGHT(TRIM(A2),4). - RIGHT on an amount shown as £1,250.00 returns 250, not .00.Formatting isn't part of the value; RIGHT sees the stored number 1250. Use TEXT to format it first if you need the shown text.
- The result looks like a number but SUM ignores it.RIGHT returns text. Convert it with VALUE, or add zero:
=RIGHT(A2,4)+0.
Practise RIGHT with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.