RIGHT in Excel: Extract the Last N Characters | 5 Examples + Cheat Sheet | Sheets & Cells
Function · Text

RIGHT — Extract Characters from the End

The mirror image of LEFT. Same syntax, opposite side — RIGHT pulls characters from the END of a string. The go-to for extracting file extensions, last-4-digits of phone or SSN, order sequence numbers, and any suffix. Paired with LEN and FIND, it handles variable-length extensions with elegant math.

Universal support since Excel 1.0
Works identically in Excel 365, 2021, 2019, 2016, 2013, 2010, 2007, 2003, Excel for the web, Google Sheets, LibreOffice, and Apple Numbers. Ship anywhere — RIGHT just works.
Quick answer
RIGHT pulls a specified number of characters from the END of a text string and returns them as a new string. Two arguments: the source text, and how many characters to take from the end.
Syntax
=RIGHT(text, [num_chars])
Working example
=RIGHT("REG-WA-2026-001", 3) → Returns "001" — the last 3 characters (the sequence number). If num_chars is omitted, RIGHT returns just the last character. =RIGHT("REG-WA-2026-001") returns "1".
📗 Free LEFT + RIGHT + MID example workbook
9 sheets · 10-row structured-text table · LEFT basics · RIGHT basics · MID basics · full code parse · RIGHT+FIND killer pattern · 10-pattern cheat sheet · compatibility matrix
Download .xlsx (free) Open in Sheets
Category
Text
Difficulty
Beginner
Excel version
All (1.0+)
Companion
FIND + LEN
1985
In Excel since v1.0
2
Arguments (1 required)
100%
Cross-version support
8/10
Templates using it

Syntax breakdown

RIGHT takes two arguments. Only the first is required.

ArgumentTypeWhat it does
text REQUIRED The source string. Cell reference, literal text in quotes, number (converted to text), or the result of another function.
num_chars OPTIONAL How many characters to extract from the end. Must be zero or positive. If omitted, defaults to 1. If greater than the string length, returns the whole string (no error).
Direction matters, syntax doesn't: RIGHT and LEFT have identical argument signatures. The only thing different is which end they pull from. If you know LEFT, you already know RIGHT.

Five working examples

Every example uses the 10-row structured-text table from the workbook — product codes, phone numbers, emails, filenames, and order IDs.

01 Fixed-length suffix — extract sequence number

Product codes end with a 3-digit sequence number: 001, 002, etc. Pull just those.

=RIGHT(B2, 3)
Returns "001" from REG-WA-2026-001
Product CodeType (LEFT 3)Sequence (RIGHT 3)
REG-WA-2026-001REG001
REG-CA-2026-002REG002
INT-EU-2026-003INT003
REG-CA-2026-004REG004
INT-AS-2026-005INT005

Once the sequence is extracted, you can sort by it, detect gaps in numbering, or convert to a number with VALUE for math. RIGHT turns a monolithic code into structured data.

02 Last 4 digits — phone, SSN, credit card

The classic privacy/display pattern. Show only the last 4 digits when the rest is sensitive.

=RIGHT(C2, 4)
Returns "0142" from 512-555-0142

Masked display — hide the rest

="***-***-" & RIGHT(C2, 4)
Returns "***-***-0142" — customer-facing phone display

SSN masking

="XXX-XX-" & RIGHT(A2, 4)
The universal "last 4" pattern for SSN. Same shape works for credit cards, bank accounts, employee IDs.
Every real business uses this. Customer service showing "Your card ending in 1234", banks showing "Account ****-5678", HR showing "SSN ending in 9012" — all the same RIGHT(field, 4) formula under the hood.

03 File extension — the fragile fixed approach

Extract file extensions with fixed-length RIGHT. Works until it doesn't.

=RIGHT(E2, 3)
Returns "pdf" from Q1-Report-2026.pdf

Where it breaks

FilenameRIGHT(3)RIGHT(4)What we want
Q1-Report-2026.pdfpdf.pdfpdf
Budget-2026-Final.xlsxlsxxlsxxlsx
Marketing-Plan.docxocxdocxdocx
Sales-Data.csvcsv.csvcsv

No single number works. pdf and csv need RIGHT 3; xlsx and docx need RIGHT 4. Some extensions (.jpeg) even need 4 while others (.jpg) need 3 for the same image type. Fixed-length RIGHT is fundamentally the wrong tool. Solution: RIGHT+LEN+FIND (Example 4).

⚠️
The file-extension trap
Any time you're pulling something whose length varies (extensions, sequences with growing digit counts, addresses with variable zip formats), fixed-length RIGHT will fail on SOME rows in your data. The bug is silent — no error, just wrong output. Whenever the piece you want isn't a fixed length, use the RIGHT+LEN+FIND pattern in Example 4.

04 RIGHT + LEN + FIND — the extension solver

Extract file extensions of ANY length by calculating num_chars dynamically.

=RIGHT(E2, LEN(E2) - FIND(".", E2))
Returns "pdf" from Q1-Report-2026.pdf — but also handles xlsx, docx, csv correctly
FilenameLENFIND(".")DiffExtension
Q1-Report-2026.pdf18153pdf
Budget-2026-Final.xlsx22184xlsx
Marketing-Plan.docx19154docx
Sales-Data.csv14113csv
Analysis-2026.xlsx18144xlsx

Each row gets its own num_chars — 3 for pdf, 4 for xlsx, 3 for csv. RIGHT never had to know upfront. The math is: total length minus position of the dot equals how many characters live AFTER the dot.

The RIGHT+LEN+FIND math, visualized

The formula is compact but the reasoning trips people up. Here's what each part contributes, using Q1-Report-2026.pdf as our example:

Reading the pattern

=RIGHT(filename, LEN(filename) − FIND(".", filename))
STEP 1
LEN — total length
LEN("Q1-Report-2026.pdf")
= 18
STEP 2
FIND — position of "."
FIND(".", "Q1-Report-2026.pdf")
= 15
STEP 3
Subtract → chars AFTER the dot
18 − 15
= 3
RESULT
RIGHT("Q1-Report-2026.pdf", 3) → "pdf"

The key insight: LEN gives you the total string length. FIND tells you where the delimiter sits. Their difference is exactly how many characters live AFTER the delimiter — which is what RIGHT needs to take. This same pattern works for ANY delimiter: dot, slash, hyphen, space, whatever separates "what you want" from "what you don't."

Compare with LEFT+FIND: the LEFT version is simpler — =LEFT(text, FIND(".", text) - 1). Just subtract 1 from the position. But RIGHT needs LEN in there because "how many chars from the end" doesn't have a direct positional readout — you always compute it via the total length. This is why LEFT+FIND feels intuitive and RIGHT+LEN+FIND takes a beat to grok.

05 Everything after the last delimiter

A common variant: extract everything after the LAST occurrence of a delimiter — like the file extension when filenames contain multiple dots.

=RIGHT(E2, LEN(E2) - FIND("@", SUBSTITUTE(E2, ".", "@", LEN(E2) - LEN(SUBSTITUTE(E2, ".", "")))))
The classic "last dot" hack. Works but reads like an obfuscated puzzle.

What this monster does: counts how many dots are in the string, uses SUBSTITUTE to replace the LAST dot with an "@" (a placeholder that shouldn't appear elsewhere), FIND locates that "@", then RIGHT grabs everything past it. Legacy patch that predates the modern alternatives.

The modern way: On Excel 365, use TEXTAFTER with the fourth argument: =TEXTAFTER(E2, ".", -1). The -1 means "search from the end" — much cleaner. See the modern alternatives section below.

Simple case — one delimiter

When you know there's only one delimiter (like our Q1-Report-2026.pdf filenames), the simple Example 4 pattern is enough. Save the SUBSTITUTE hack for cases like archive.tar.gz where you actually need "everything after the LAST dot."

Interactive playground

Try it Live RIGHT demonstration

Mirrors live cells from the workbook. Edit the yellow inputs → the blue answer updates.

Input · Phone
512-555-0142
Output · Last 4
0142
=RIGHT(C2, 4)
Input · Filename
Budget-2026-Final.xlsx
Output · Extension
xlsx
=RIGHT(E2, LEN(E2) - FIND(".", E2))

Download the workbook to try RIGHT patterns across the full 10-row structured-text table.

The RIGHT cheat sheet — 10 patterns for daily use

Copy any of these, adapt to your data, and you're 80% of the way there:

10 patterns you'll use every day

From simplest fixed-length pulls to the dynamic RIGHT+LEN+FIND file-extension solver.

1Last N chars (fixed)
=RIGHT(A2, 4)
Grab the last 4 characters. Common for masking sensitive data.
2Just the last char
=RIGHT(A2)
Omit num_chars — defaults to 1. Check-digit or status indicator.
3File extension (dynamic)
=RIGHT(A2, LEN(A2) - FIND(".", A2))
Handles pdf, docx, xlsx, csv — any extension length.
4Email domain
=RIGHT(A2, LEN(A2) - FIND("@", A2))
Everything after the "@". Same pattern as extension.
5Masked phone display
="***-***-" & RIGHT(A2, 4)
Show last 4, mask the rest. Customer-facing pattern.
6Card-ending display
="ending in " & RIGHT(A2, 4)
The universal payment-UI phrasing.
7Safe with IFERROR
=IFERROR(RIGHT(A2, LEN(A2)-FIND(".", A2)), A2)
If no "." exists, return the whole string as fallback.
8Trailing year
=RIGHT(A2, 4)
Pull the year from strings ending in a 4-digit year.
9Half the string (end)
=RIGHT(A2, LEN(A2)/2)
Second half of a string. Combine LEN for proportional pulls.
10Last word
=RIGHT(A2, LEN(A2) - FIND("*", SUBSTITUTE(A2, " ", "*", LEN(A2)-LEN(SUBSTITUTE(A2, " ", "")))))
Advanced: last word using the SUBSTITUTE-last-occurrence hack.

The Text-Extract family — three ways to slice

Meet the family

Excel has three foundational text-slicing functions. Each pulls from a different position. This page is RIGHT — pulls from the end.

Same syntax across the triofunction(text, num_chars) for LEFT and RIGHT, plus a start position for MID. All ship in every Excel version.

Excel 365 alternative — TEXTAFTER

If you're on Excel 365, TEXTAFTER replaces the RIGHT+LEN+FIND pattern with clean syntax. Bonus: the -1 match-mode grabs everything after the LAST occurrence — so no more SUBSTITUTE hack for multi-delimiter strings.
Old way (universal)
=RIGHT(A2, LEN(A2) - FIND(".", A2))
New way (Excel 365)
=TEXTAFTER(A2, ".")

Common errors and how to fix them

Like LEFT, RIGHT rarely errors on its own — the FIND part of RIGHT+FIND does. Six common scenarios:

ResultWhy it happensBroken → Fix
VALUE error FIND didn't find the delimiter. Common with inconsistent data. =RIGHT(A2, LEN(A2)-FIND(".", A2)) // errors on "no-extension" =IFERROR(RIGHT(A2, LEN(A2)-FIND(".", A2)), "")
Wrong extension Fixed-length RIGHT truncated a 4-char extension to 3. =RIGHT("Report.xlsx", 3) // "lsx" — wrong! =RIGHT(A2, LEN(A2) - FIND(".", A2))
Includes the dot Off-by-one in the RIGHT+FIND math — used FIND-1 instead of just FIND. =RIGHT(A2, LEN(A2) - FIND(".", A2) + 1) // ".pdf" =RIGHT(A2, LEN(A2) - FIND(".", A2)) // "pdf"
Wrong dot FIND locates the FIRST dot. In "archive.tar.gz" you probably wanted the last. =RIGHT(A2, LEN(A2)-FIND(".", A2)) // "tar.gz" Use the SUBSTITUTE-last-occurrence pattern or TEXTAFTER
Negative num_chars LEN - FIND went negative because FIND returned a bigger number. Can happen with weird data Wrap in MAX(0, LEN - FIND) or use IFERROR
Trailing whitespace Source has trailing spaces — RIGHT returns spaces instead of the last "real" chars. =RIGHT("hello ", 3) // returns "lo " with a space =RIGHT(TRIM(A2), 3)
📗 Every example above, in one workbook
Basic RIGHT · last-4 masking · file extensions · RIGHT+LEN+FIND · SUBSTITUTE-last-occurrence · cheat sheet · compat matrix.
Download text-extract-examples-2026.xlsx

Related functions

Complementary functions

Excel version compatibility

RIGHT has been in Excel since version 1.0. Every platform supports it identically:

PlatformSupports RIGHT?Notes
Excel 365 (Windows & Mac)✓ YesFull support
Excel 2021 / 2019 / 2016 / 2013 / 2010 / 2007 / 2003✓ YesFull support
Excel for the web✓ YesFull support
Excel on iPad & iPhone✓ YesFull support
Google Sheets✓ YesSame syntax
LibreOffice Calc✓ YesFull support
Apple Numbers✓ YesFull support
Special variant: RIGHTB counts bytes instead of characters — useful for double-byte character sets. If your data is standard text, use regular RIGHT.

When to use RIGHT vs. alternatives

Use RIGHT when…

  • The piece you want is at the END of the string. That's the whole point.
  • Fixed-length suffixes. Last 4 of phone, 3-digit sequence, year in YYYY.
  • You need universal Excel support. Works in every version, every platform.

Use RIGHT+LEN+FIND instead of just RIGHT when…

  • The suffix length varies. File extensions, email domains, sequence numbers that grow.
  • There's a consistent delimiter marking where "the good part" begins.

Use TEXTAFTER (Excel 365) instead when…

  • You're on Excel 365 and want the cleanest possible syntax.
  • You need "after the LAST occurrence" — TEXTAFTER's -1 match-mode is elegant.

Use LEFT instead when…

  • The piece you want is at the START of the string.

Use MID instead when…

  • The piece is in the middle — you have a clear start position and length.

How RIGHT actually works

The algorithm

RIGHT calculates the string length, then returns the substring from position (length - num_chars + 1) to the end. If num_chars is greater than the length, RIGHT returns the whole string with no error.

Number and date handling

Numbers are converted to their default text representation. So RIGHT(1234.5, 3) returns "4.5". Dates become their serial number. Wrap in TEXT() to preserve formatting: =RIGHT(TEXT(A2, "yyyy-mm-dd"), 2) to get the day portion of a date.

Whitespace surprises

Trailing spaces in the source count as characters. RIGHT("hello ", 3) returns "lo " — with the space. If your data may have trailing whitespace, wrap the source in TRIM: RIGHT(TRIM(A2), 3).

What num_chars=0 does

RIGHT with num_chars=0 returns an empty string — no error. Useful in conditional formulas where you sometimes want no output.

Performance notes

RIGHT is fast. A million calls run in fractions of a second.

  • Slightly slower than LEFT. RIGHT has to compute the length internally to know where to start. Negligible in practice.
  • RIGHT+LEN+FIND. Three function calls per formula — still very fast, but not free at scale.
  • SUBSTITUTE-based patterns. The "last occurrence" hack calls SUBSTITUTE twice on the full string. Slowest of the RIGHT patterns but still fast enough for most use.

How to write a RIGHT from scratch

  1. Identify the source and the piece you want

    What are you extracting FROM, and how does the piece you want relate to the end?

  2. Decide: fixed or variable length?

    Fixed like "last 4 of phone" → just RIGHT. Variable like "file extension" → RIGHT+LEN+FIND.

  3. Fixed → just use a number

    =RIGHT(A2, 4). Simplest form.

  4. Variable → use RIGHT+LEN+FIND

    =RIGHT(A2, LEN(A2) - FIND("delimiter", A2)). LEN minus delimiter position = chars AFTER.

  5. Guard with IFERROR when data varies

    =IFERROR(RIGHT(A2, LEN(A2)-FIND(".", A2)), A2). Handles rows lacking the delimiter.

Functions used with RIGHT

🎁 Grab the free LEFT + RIGHT + MID workbook
9 sheets covering everything on this page — basics, RIGHT+LEN+FIND patterns, structured code parsing, cheat sheet.
Download text-extract-examples-2026.xlsx

Frequently asked questions

What's the difference between RIGHT and LEFT?

RIGHT extracts characters from the END of a string; LEFT extracts from the START. Same syntax, opposite direction. RIGHT("REG-WA", 2) returns "WA"; LEFT("REG-WA", 3) returns "REG".

How do I get a file extension of unknown length?

=RIGHT(filename, LEN(filename) - FIND(".", filename)). The math: total length minus position of the dot equals how many characters live AFTER the dot. Works for pdf (3), xlsx (4), csv (3), and any other extension length.

Why does my RIGHT include the delimiter?

Off-by-one error. You probably added 1 or forgot to subtract in the num_chars math. Correct formula for extracting "pdf" from "file.pdf" is =RIGHT(A2, LEN(A2) - FIND(".", A2)) — NOT + 1 anywhere.

What happens if num_chars is larger than the string?

RIGHT returns the whole string with no error. So RIGHT("Hi", 100) returns "Hi". Defensive-by-default.

Does RIGHT work in Google Sheets?

Yes, identically. Same syntax in Google Sheets, LibreOffice, and Apple Numbers.

How do I get everything after the LAST dot?

Two options. On Excel 365: =TEXTAFTER(A2, ".", -1) — the -1 means search from end. On older Excel: use the SUBSTITUTE-last-occurrence hack shown in Example 5 (works but ugly). Or use FIND with the actual count of dots via LEN - LEN(SUBSTITUTE(...)).

Can I use RIGHT to remove characters from the end?

Backwards — LEFT is the tool for that. =LEFT(A2, LEN(A2) - 3) removes the last 3 characters. RIGHT KEEPS the end, LEFT KEEPS the start (which is everything except the end).

Can RIGHT return a number?

No — always text. Even "1234" extracted from "code-1234" is text. Wrap in VALUE() or double-negative (--) to convert: =VALUE(RIGHT(A2, 4)).

Why does RIGHT return trailing spaces from my data?

Your source has trailing whitespace. Wrap in TRIM: =RIGHT(TRIM(A2), 3).

Is RIGHT case-sensitive?

RIGHT preserves case. But if you're using RIGHT+FIND, FIND is case-sensitive. Use SEARCH for case-insensitive matching.

Should I use RIGHT+FIND or TEXTAFTER?

TEXTAFTER is cleaner but Excel 365 only. RIGHT+LEN+FIND is universal. If you might share the workbook with older Excel users, stick with RIGHT. If you're on 365 and don't care about backward compatibility, TEXTAFTER wins.

Which templates use RIGHT?

Templates that display masked identifiers or parse sequence numbers. Prominently: Invoice (last-4 of payment reference), Sales Dashboard (sequence from product code), KPI Dashboard (period suffix), Employee Attendance (last 4 of badge), Timesheet (task sequence), Inventory Tracker (SKU sequence), Project Timeline (task suffix), and Expense Report (transaction reference last 4).

Templates that use RIGHT

8 of our 10 templates use RIGHT for parsing sequences, masking identifiers, and extracting suffixes:

Skip the syntax. Ask in plain English.

The Sheets & Cells AI Add-in writes RIGHT, RIGHT+LEN+FIND, and every text-extraction pattern — right inside Excel. Type "get the file extension" and get the working formula, ready to paste.

Try the AI Add-in →