RIGHT Function

Excel Functions › Text

All Excel versions Text

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.


Quick answer: to grab the last 4 characters of the text in A2:
=RIGHT(A2, 4)
Omit the second argument for just the final character. For everything after a delimiter, combine with LEN and FIND: =RIGHT(A2, LEN(A2) - FIND(".", A2)).

Syntax

=RIGHT(text, [num_chars])
ArgumentDescription
textRequiredThe text string (or cell reference) to extract from.
num_charsOptionalHow 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:

AB
1PhoneLast 4
2(214) 555-01170117
3(817) 555-09030903
4(972) 555-02380238
=RIGHT(A2, 4) // returns "0117"

Note the leading zero survives — because the result is text. The single-character default is useful too:

=RIGHT(A2) // last character only

Try it: interactive RIGHT demo

Live 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:

=RIGHT(A2, LEN(A2) - FIND(".", A2)) // "report.pdf" becomes "pdf"

Same pattern for the last name in a two-word name (everything after the space):

=RIGHT(A2, LEN(A2) - FIND(" ", A2)) // "Sarah Connor" becomes "Connor"

And the beloved leading-zeros trick — pad any ID to a fixed width by gluing zeros on the front and keeping the right 5:

=RIGHT("00000" & A2, 5) // 42 becomes "00042"

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

📊
Download the free RIGHT practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

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?
Glue zeros on and keep the right N characters: =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?
Because RIGHT returns text. "2026" (text) is not equal to 2026 (number) in lookups or comparisons. Convert with =VALUE(RIGHT(A2, 4)) or add 0 to the result.
What if num_chars is longer than the string?
RIGHT returns the entire string with no complaint. Only a negative num_chars produces an error.
How do I get the last word of a sentence?
For two words, =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

Related functions: LEFT · MID · LEN · FIND · TEXTAFTER · TRIM