RIGHT function
RIGHT returns a set number of characters from the end of a text string. It's the quick way to grab the last digits of a phone or account number, a file extension, or the sequence number at the end of an ID.
- Available in
- Every current version
- Category
- Text functions
- Returns
- Text: the last num_chars characters, or the whole string if it is shorter than that.
- Google Sheets
- Works the same in Google Sheets.
Syntax
=RIGHT(text, [num_chars])
| Argument | Required? | What it is |
|---|---|---|
text | Required | The text or cell to read from. |
num_chars | Optional | How many characters to return. Leave it out to get just the last character. |
Examples
Each result below is calculated from the sample sheet by our formula engine, the same one that grades the practice.
| Cell | Formula | Result | What it shows |
|---|---|---|---|
| D2 | =RIGHT(A2,5) | 00418 | The last five characters, leading zeros intact |
| D3 | =RIGHT(B3,4) | 0193 | The last four digits of a phone number |
| D4 | =RIGHT(C4,LEN(C4)-FIND(".",C4)) | docx | The file extension, whatever its length |
Try it live
This is the sample sheet. Change any number or text, or edit a formula, and the results update.
Show the sample data as a table
| Account | Phone | File | Result |
| ACCT-00418 | 612-555-0148 | q3-report.xlsx | 00418 |
| ACCT-01277 | 763-555-0193 | budget.csv | 0193 |
| ACCT-00093 | 952-555-0107 | notes.docx | docx |
Practice RIGHT
From lesson 13, LEFT, RIGHT, MID & LEN. Graded instantly, then re-checked on changed data.
Sequence number
C2, extract the last four characters. Fill down to C6.Common mistakes
| What you see | Why, and how to fix it |
|---|---|
| Blank or short results | Imported text often ends in spaces, so RIGHT returns them. Trim first: =RIGHT(TRIM(A2),4). |
| Leading zeros vanish when converted | RIGHT returns "00418" as text. VALUE turns it into 418, so leave it as text when the zeros matter. |
| Decimals come back oddly | RIGHT reads the stored value, not the display. A price shown as $5.50 is stored as 5.5, so =RIGHT(A2,2) returns ".5". Format it first: =RIGHT(TEXT(A2,"0.00"),2). |
Tips
- Drop the first n characters with =RIGHT(A2,LEN(A2)-n).
- For the text after the last delimiter, =TEXTAFTER(A2,"-",-1) is simpler in Excel 2024 and Microsoft 365.
Questions
How do I get the last 4 digits in Excel?
Use =RIGHT(A2,4). The result is text, so wrap it in VALUE if you need to do math with it.
How do I remove the last character in Excel?
Keep everything but the last character with LEFT: =LEFT(A2,LEN(A2)-1).
Lessons that use RIGHT
Last reviewed October 2026. Every example result on this page is calculated live by the Spreadsheet Practice formula engine.