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.
Syntax breakdown
RIGHT takes two arguments. Only the first is required.
| Argument | Type | What 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). |
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.
REG-WA-2026-001| Product Code | Type (LEFT 3) | Sequence (RIGHT 3) |
|---|---|---|
| REG-WA-2026-001 | REG | 001 |
| REG-CA-2026-002 | REG | 002 |
| INT-EU-2026-003 | INT | 003 |
| REG-CA-2026-004 | REG | 004 |
| INT-AS-2026-005 | INT | 005 |
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.
512-555-0142Masked display — hide the rest
SSN masking
03 File extension — the fragile fixed approach
Extract file extensions with fixed-length RIGHT. Works until it doesn't.
Q1-Report-2026.pdfWhere it breaks
| Filename | RIGHT(3) | RIGHT(4) | What we want |
|---|---|---|---|
| Q1-Report-2026.pdf | |||
| Budget-2026-Final.xlsx | lsx | xlsx | xlsx |
| Marketing-Plan.docx | ocx | docx | docx |
| Sales-Data.csv | csv | .csv | csv |
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).
04 RIGHT + LEN + FIND — the extension solver
Extract file extensions of ANY length by calculating num_chars dynamically.
Q1-Report-2026.pdf — but also handles xlsx, docx, csv correctly| Filename | LEN | FIND(".") | Diff | Extension |
|---|---|---|---|---|
| Q1-Report-2026.pdf | 18 | 15 | 3 | |
| Budget-2026-Final.xlsx | 22 | 18 | 4 | xlsx |
| Marketing-Plan.docx | 19 | 15 | 4 | docx |
| Sales-Data.csv | 14 | 11 | 3 | csv |
| Analysis-2026.xlsx | 18 | 14 | 4 | xlsx |
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
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."
=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.
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.
=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.
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.
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 trio — function(text, num_chars) for LEFT and RIGHT, plus a start position for MID. All ship in every Excel version.
Excel 365 alternative — TEXTAFTER
-1 match-mode grabs everything after the LAST occurrence — so no more SUBSTITUTE hack for multi-delimiter strings.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:
| Result | Why it happens | Broken → 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) |
Related functions
Complementary functions
Excel version compatibility
RIGHT has been in Excel since version 1.0. Every platform supports it identically:
| Platform | Supports RIGHT? | Notes |
|---|---|---|
| Excel 365 (Windows & Mac) | ✓ Yes | Full support |
| Excel 2021 / 2019 / 2016 / 2013 / 2010 / 2007 / 2003 | ✓ Yes | Full support |
| Excel for the web | ✓ Yes | Full support |
| Excel on iPad & iPhone | ✓ Yes | Full support |
| Google Sheets | ✓ Yes | Same syntax |
| LibreOffice Calc | ✓ Yes | Full support |
| Apple Numbers | ✓ Yes | Full support |
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
-1match-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
-
Identify the source and the piece you want
What are you extracting FROM, and how does the piece you want relate to the end?
-
Decide: fixed or variable length?
Fixed like "last 4 of phone" → just RIGHT. Variable like "file extension" → RIGHT+LEN+FIND.
-
Fixed → just use a number
=RIGHT(A2, 4). Simplest form. -
Variable → use RIGHT+LEN+FIND
=RIGHT(A2, LEN(A2) - FIND("delimiter", A2)). LEN minus delimiter position = chars AFTER. -
Guard with IFERROR when data varies
=IFERROR(RIGHT(A2, LEN(A2)-FIND(".", A2)), A2). Handles rows lacking the delimiter.
Functions used with RIGHT
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 →