← Functions
righttextfunctionsbeginner

Excel RIGHT Function

RIGHT extracts a set number of characters from the end of a text string, returning them as text.

RIGHT pulls a specific number of characters from the end of a text string and returns them as text. It's one of Excel's simplest functions, but it trips people up in two specific ways: it always returns text, even when the source looks like a number, and it can't read a date's displayed value, only its underlying serial number. Both of those cause quiet, wrong-looking results rather than errors.

Available in: all Excel versions, including Excel 365, 2021, 2019, and 2016. TEXTAFTER, mentioned later in this article as a newer alternative for some use cases, requires Excel 365 or Excel 2024.

Syntax

=RIGHT(text, [num_chars])
ParameterRequiredDescription
textYesThe string you're pulling characters from. Can be a cell reference, a typed string in quotes, or the result of another formula.
num_charsNoHow many characters to grab, counted from the last character backward. Defaults to 1 if omitted.

RIGHT always returns text, even when the source is a number. =RIGHT(15000, 3) returns the text string "000", not the number 000. If you feed that into a math formula, Excel will usually convert it automatically, but comparisons and lookups can fail silently. Wrap the result in VALUE() when you need an actual number.

Basic Example

You're cleaning up a list of invoice numbers like "INV-2026-0847" and need just the last four digits.

=RIGHT(A2, 4)

// A2       = the full invoice number, "INV-2026-0847"
// 4        = how many characters to pull from the end

RIGHT counts backward from the last character and grabs four of them, returning "0847". Note that it's still a text string, not a number, so leading zeros survive the extraction. If you tried this with LEFT instead, you'd get "INV-" from the start of the string instead.

How RIGHT Works

It counts from the end, not a fixed position

RIGHT doesn't care how long the string is. Give it =RIGHT("Chicago", 3) and you get "ago", the last three characters, regardless of what came before them. This matters when your strings vary in length, like product names or file paths; RIGHT adjusts automatically as long as you're always after the last N characters.

num_chars defaults to 1 if you leave it out

=RIGHT(A2) with no second argument returns just the single last character. This is easy to forget when you're building formulas quickly and expect a longer result. Always include num_chars explicitly unless you genuinely want one character.

Overflow doesn't error, it just returns everything

If num_chars is larger than the string itself, RIGHT doesn't throw an error. =RIGHT("Excel", 20) simply returns "Excel", the entire string. This is useful defensively: you can set num_chars generously without worrying about breaking short entries.

It ignores formatting and case

RIGHT reads the underlying value, not what's displayed. A cell formatted to show "$1,200.00" but actually containing the number 1200 will return characters based on 1200, not the formatted string. RIGHT also treats uppercase and lowercase identically; there's no case-sensitive variant, unlike EXACT.

Common Use Cases

Pulling a file extension

You have a list of filenames in column B and want just the extension.

=RIGHT(B2, 3)   // returns "xls" from "report.xls"

This only works reliably if every extension is exactly three characters. For mixed-length extensions like ".xlsx" or ".csv", pair RIGHT with FIND instead (see below).

Extracting a last name from "First Last"

Names in column C are stored as "Michael Torres" and you need just the surname.

=RIGHT(C2, LEN(C2) - FIND(" ", C2))

// C2              = the full name
// FIND(" ", C2)   = the position of the space
// LEN(C2)         = total character count

FIND locates the space, LEN gets the total length, and subtracting the two tells RIGHT exactly how many characters to grab after that space. This handles names of any length without hardcoding a character count.

Building a masked account number

For a customer statement, you want to show only the last four digits of a stored account number and hide the rest.

="****" & RIGHT(D2, 4)   // returns "****4821" from "88213304821"

The & operator glues a static mask onto the extracted digits. This is a common pattern in finance and billing sheets where full account numbers shouldn't display on printed reports.

Splitting a coded ID after the last dash

Order codes like "REG-WEST-2026-1042" need just the trailing sequence number, and the number of dashes before it isn't consistent across every row.

=RIGHT(E2, LEN(E2) - FIND("@", SUBSTITUTE(E2, "-", "@", LEN(E2) - LEN(SUBSTITUTE(E2, "-", "")))))

This nested formula finds the position of the last dash by substituting only the final occurrence with a placeholder character, then uses RIGHT to grab everything after it. It looks dense, but it's the standard workaround for "extract text after the last delimiter" when you're not on a version with TEXTAFTER.

Handling Errors

RIGHT rarely throws an error on its own, since it accepts almost any input as text. The two situations that do trigger a catchable error:

Common causes of #VALUE!:

  • num_chars is negative (Excel can't extract a negative number of characters)
  • num_chars is text that can't convert to a number, like "four" instead of 4
  • The text argument references a cell containing an error value that propagates through
=IFERROR(RIGHT(A2, B2), "Check num_chars")

If num_chars comes from a formula elsewhere in the sheet (like the LEN/FIND combination above), that upstream formula is usually the real source of a #VALUE! error. Check it before assuming RIGHT itself is broken.

Notes & Gotchas

Why does RIGHT return the wrong result on a date?

Because dates are stored as serial numbers, not as the text you see on screen. =RIGHT(A1, 4) on a cell showing "3/14/2026" doesn't return "2026". It reads the serial number behind that date, which might be something like 46095, and returns the last four digits of that number instead. To pull a year from an actual date, use =YEAR(A1), not RIGHT.

Why does RIGHT return text instead of a number?

RIGHT is a text function, so its output is always a text string, even when every character in it is a digit. This becomes a problem in SUMIFS criteria, VLOOKUP lookups, or any formula expecting a true number. Wrap the result in VALUE(), like =VALUE(RIGHT(A2, 4)), to force a numeric result.

What happens if num_chars is greater than the length of the text?

Nothing breaks. RIGHT simply returns the full string if num_chars exceeds the total character count. This makes RIGHT safe to use with a generous, fixed num_chars value across rows of varying length, since short entries won't error out.

Does RIGHT work with numbers, not just text?

Yes, RIGHT accepts a number directly and treats it as text internally. =RIGHT(48920, 2) returns "20". The catch is the same one covered above: the result comes back as a text string, so if you need to do math with it afterward, wrap it in VALUE().

Is RIGHT still worth using in Excel 365?

For fixed-length extractions, yes, RIGHT is still the simplest tool. For anything based on a delimiter, position, or "everything after the last dash," TEXTAFTER usually replaces the LEN/FIND/SUBSTITUTE combinations RIGHT traditionally required, with a single readable formula.

Related Functions

FunctionUse this when...
LEFTYou need characters from the start of a string instead of the end.
MIDThe characters you need are somewhere in the middle, not at either edge.