Part of the free Module 5: Excel Formulas and Functions · Function 73 of 105 · Full Excel course
The Excel RIGHT function returns a specified number of characters from the end of a text string. With one argument it returns the last character; with a count it returns that many characters counted from the right. RIGHT is used to pull out suffixes, file extensions, the last digits of an ID or everything after a fixed-length prefix, usually together with LEN, FIND or SEARCH.
Syntax
=RIGHT(text, [num_chars])
Arguments
| Argument | Required / Optional | Meaning |
|---|---|---|
| text | Required | The text string or cell reference to extract from. Numbers are converted to text first. |
| num_chars | Optional | How many characters to return from the end. Default is 1. Must be zero or positive; a value larger than the text length returns the whole text. |
How RIGHT works
RIGHT counts characters, including spaces, from the last character backwards and returns them in their original order. The result is always text: =RIGHT(20260904,2) returns the text “04”, not the number 4. Wrap the result in VALUE, or add 0, when a number is needed. RIGHT reads the stored value, not the formatted display, so a date returns the last digits of its serial number unless you apply TEXT first. For double-byte languages, RIGHTB counts bytes instead of characters.
Step-by-step example: extract the file extension
- Column A holds file names such as
Quarterly_Report_2026.xlsx. - In B2 enter
=RIGHT(A2,LEN(A2)-FIND(".",A2)). - Press Enter. FIND locates the full stop, LEN gives the total length and the difference is the number of characters after the dot, so RIGHT returns
xlsx. - Fill down. For names with several dots, replace FIND(“.”,A2) with the last-occurrence formula shown in the tips below.
Practical use cases
1. Last four digits of a card or account number
=RIGHT(A2,4)
2. Remove a fixed-length prefix
=RIGHT(A2,LEN(A2)-4)
Strips “INV-” from INV-00417 regardless of how long the remainder is.
3. Last name from a full name
=RIGHT(A2,LEN(A2)-FIND(" ",A2))
Works for two-word names. For names with middle names, use the last-space technique in the tips section.
4. Year from a text date such as 04/09/2026
=VALUE(RIGHT(A2,4))
5. Check a code ends with a specific suffix
=RIGHT(A2,3)="-UK"
Returns TRUE or FALSE for filtering or conditional formatting.
Common mistakes and tips
- #VALUE! error: num_chars is negative, usually because LEN minus FIND went below zero when the separator was missing. Wrap the formula in IFERROR.
- Trailing spaces: RIGHT returns the space as the last character. Clean the text with TRIM first.
- Text after the last separator: FIND locates the first occurrence only. To get text after the last space use
=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",100)),100)). - Leading zeros: RIGHT keeps them because the result is text; converting with VALUE removes them again.
- Excel 365 alternative: TEXTAFTER(A2,”.”,-1) returns the text after the last dot without any LEN or FIND arithmetic.
RIGHT compared with LEFT, MID and TEXTAFTER
LEFT, MID and RIGHT are the classic extraction trio. RIGHT is anchored to the end of the string, so it is the natural choice when the piece you want is a suffix or when the prefix has a known fixed length. MID is more general but needs an explicit start position, and LEFT is anchored to the beginning. In Excel 365 and Excel 2024, TEXTAFTER covers many RIGHT scenarios more readably: =TEXTAFTER(A2,"-") returns everything after the first hyphen and =TEXTAFTER(A2," ",-1) returns the last word. TEXTAFTER also has an argument for what to return when the delimiter is missing, which removes the need for IFERROR. For workbooks that must open in Excel 2019 or earlier, keep the RIGHT with LEN and FIND pattern.
Related functions
- LEFT: extracts characters from the start of the text.
- MID: extracts characters from any position.
- LEN: supplies the total length for RIGHT calculations.
- FIND: locates the separator that RIGHT extracts after.
- See all lessons in the Excel Formulas course.
Frequently asked questions
How do I extract text after a specific character with RIGHT?
Combine RIGHT with LEN and FIND: =RIGHT(A2,LEN(A2)-FIND(“-“,A2)) returns everything after the first hyphen.
Why does RIGHT return the wrong digits for a date?
RIGHT works on the stored serial number, not the displayed date. Use =RIGHT(TEXT(A2,”dd/mm/yyyy”),4) to get the year as displayed.
How do I get the last word in a cell?
Use =TRIM(RIGHT(SUBSTITUTE(A2,” “,REPT(” “,100)),100)), or in Excel 365 =TEXTAFTER(A2,” “,-1).
Need a ready-made template? Browse 7,000+ Excel, Power BI and Google Sheets templates at NextGenTemplates.com.