RIGHT function
Returns a set number of characters from the end of a text string, e.g. the last 4 digits of a phone or account number.
Available in All versions of Excel, including Microsoft 365, Excel for Mac and Excel for the web
In every Excel versionWorks in Google Sheets
Syntax
RIGHT(text, [num_chars])| Argument | What it means | |
|---|---|---|
text | Required | The text or cell to take characters from. |
num_chars | Optional | How many characters to return. Default 1. |
Returns: Text: the last num_chars characters.
How RIGHT works
RIGHT is the mirror image of LEFT: it takes characters from the end of the text. =RIGHT(A2,4) gives the last four digits of a phone number, the numeric part of NYC-1042 or the file extension of report.xlsx (with 4 characters).
For parts with variable length, work out how many characters to keep with LEN(A2) - position of the delimiter. For example =RIGHT(A2,LEN(A2)-FIND(" ",A2)) returns everything after the first space, i.e. the surname in Maria Lopez. In Microsoft 365, TEXTAFTER does the same thing more readably and can also start from the last delimiter.
RIGHT reads the stored value, not the formatted display. A cell showing $1,250.50 stores 1250.5, so RIGHT(A2,2) returns .5. Convert the cell with TEXT first if you need the displayed characters. The result is always text.
Examples
1Last four digits of a phone number
| A | B | |
|---|---|---|
| 1 | Phone | |
| 2 | +30 210 555 0147 | 0147 |
Result: 0147
The last four characters are returned; leading zeros are kept because the result is text.
2Number part after a hyphen
| A | B | |
|---|---|---|
| 1 | Product code | |
| 2 | NYC-1042 | 1042 |
Result: 1042
The text is 8 characters and the hyphen is at 4, so RIGHT keeps 8 - 4 = 4 characters.
3Surname from a full name
| A | B | |
|---|---|---|
| 1 | Full name | |
| 2 | Maria Lopez | Lopez |
Result: Lopez
11 characters minus the space at position 6 leaves 5 characters.
4Formatted numbers surprise
| A | B | |
|---|---|---|
| 1 | Amount | |
| 2 | 1250.5 | .5 |
Result: .5
Even if A2 is formatted as $1,250.50, it stores 1250.5, so the last two characters are .5. Use RIGHT(TEXT(A2,"0.00"),2) to get 50.
Common errors and how to fix them
| Error | Why it happens | Fix |
|---|---|---|
#VALUE! | num_chars is negative, often because the FIND in the formula failed or the delimiter is missing. | Wrap in IFERROR or check that the delimiter exists. |
Tips
- Trailing spaces count. If RIGHT seems to return too little, check the source with
=LEN(A2)and TRIM it. =RIGHT(A2,LEN(A2)-3)is a quick way to drop the first three characters.- To get the text after the last delimiter in Microsoft 365, use
=TEXTAFTER(A2,"-",-1).
Questions
How do I get everything after a character?
Use =RIGHT(A2,LEN(A2)-FIND("-",A2)) or, in Microsoft 365, =TEXTAFTER(A2,"-").
How do I remove the last few characters?
Use LEFT with a shorter length: =LEFT(A2,LEN(A2)-3) drops the last three characters.
Why does RIGHT return digits that do not add up?
RIGHT returns text. Use =VALUE(RIGHT(A2,4)) or --RIGHT(A2,4) to get a number.
Google Sheets
RIGHT also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
RIGHT in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Czech | ZPRAVA |
| Danish | HØJRE |
| Dutch | RECHTS |
| Finnish | OIKEA |
| French | DROITE |
| German | RECHTS |
| Hungarian | JOBB |
| Italian | DESTRA |
| Norwegian (Bokmål) | HØYRE |
| Polish | PRAWY |
| Portuguese (Brazil) | DIREITA |
| Portuguese (Portugal) | DIREITA |
| Russian | ПРАВСИМВ |
| Spanish | DERECHA |
| Swedish | HÖGER |
| Turkish | SAĞDAN |
Recipes that use RIGHT
- How to convert text to a date in Excel
- How to extract numbers from text in Excel
- How to split first and last name in Excel