The Excel RIGHT function is the mirror image of LEFT: it returns the last characters of a text string. Last-four digits, file extensions, trailing codes, the famous leading-zeros padding trick — whenever the interesting part of a string lives at the end, RIGHT is the tool.
=RIGHT(A2, LEN(A2) - FIND(".", A2)).
Syntax
| Argument | Description | |
|---|---|---|
text | Required | The text string (or cell reference) to extract from. |
num_chars | Optional | How many characters to take from the right end. Default is 1. Must be zero or positive; more than the string holds simply returns the whole string. |
Available in: every version of Excel. Like all text functions, RIGHT returns text — "0117" with its leading zero intact, which is usually exactly why you reached for it.
Grab the last characters of a string
The last four digits of a phone number make a handy verification column. One formula in B2, filled down:
| A | B | |
|---|---|---|
| 1 | Phone | Last 4 |
| 2 | (214) 555-0117 | 0117 |
| 3 | (817) 555-0903 | 0903 |
| 4 | (972) 555-0238 | 0238 |
Note the leading zero survives — because the result is text. The single-character default is useful too:
Try it: interactive RIGHT demo
Drag the slider and watch RIGHT peel characters off the end of a file name.
Dynamic suffixes with RIGHT + LEN + FIND
When the suffix length varies, compute it: total length minus the delimiter’s position. The classic file-extension formula:
Same pattern for the last name in a two-word name (everything after the space):
And the beloved leading-zeros trick — pad any ID to a fixed width by gluing zeros on the front and keeping the right 5:
Modern alternative: Excel 365’s TEXTAFTER replaces the LEN arithmetic — =TEXTAFTER(A2, ".", -1) even grabs text after the last dot when there are several. RIGHT remains the version-proof classic.
Errors & common pitfalls
#VALUE! — negative num_chars. Usually a RIGHT + LEN + FIND combo where FIND failed (delimiter missing) or the arithmetic went negative. Wrap the whole thing in IFERROR with a sensible fallback.
Pitfall: the result is text. =RIGHT("INV-2026", 4) returns the text "2026", which will not equal the number 2026 in comparisons or lookups. Wrap in VALUE() when you need a true number — but don’t if you are preserving leading zeros.
Pitfall: dates show their serial number. A cell displaying 6/11/2026 contains 46184 under the hood, so RIGHT(A2, 4) returns "6184". Convert with TEXT first: =RIGHT(TEXT(A2, "mm/dd/yyyy"), 4) returns "2026".
Pitfall: invisible trailing spaces. If the string ends with a stray space, RIGHT(A2, 4) includes it and your last-four looks wrong. Clean with TRIM first: =RIGHT(TRIM(A2), 4).
Practice workbook
Frequently asked questions
How do I get the file extension with RIGHT?
=RIGHT(A2, LEN(A2) - FIND(".", A2)) returns everything after the first dot. For names with multiple dots, Excel 365 users can switch to =TEXTAFTER(A2, ".", -1) to split at the last dot.How do I pad numbers with leading zeros?
=RIGHT("00000" & A2, 5) turns 42 into "00042". (The TEXT function — =TEXT(A2, "00000") — does the same job.)Why doesn't my RIGHT result match a number?
=VALUE(RIGHT(A2, 4)) or add 0 to the result.What if num_chars is longer than the string?
How do I get the last word of a sentence?
=RIGHT(A2, LEN(A2) - FIND(" ", A2)). For any number of words the classic trick replaces the last space with a marker using SUBSTITUTE, then RIGHT from there — or in Excel 365 simply =TEXTAFTER(A2, " ", -1).Master functions like this in one day
This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class