The Excel TEXTAFTER function returns everything in a text value that comes after a delimiter — the domain after the @, the file name after the last slash, the surname after the final space. It kills the infamous MID/FIND/LEN formula chains, and a negative instance number counts delimiters from the end, which used to be the hardest trick in Excel text-wrangling. Its twin is TEXTBEFORE; for all the pieces at once, use TEXTSPLIT.
instance_num = -1: =TEXTAFTER(A2, "/", -1) returns whatever follows the last slash — e.g. a file name at the end of a path.
Syntax
| Argument | Description | |
|---|---|---|
text | Required | The text to search in. |
delimiter | Required | The character(s) to look for. Can be more than one character, or an array of alternatives. |
instance_num | Optional | Which occurrence to cut at. Default 1. Negative counts from the end: -1 is the last occurrence. |
match_mode | Optional | 0 (default) = case-sensitive · 1 = case-insensitive. |
match_end | Optional | 1 treats the start/end of the text as a delimiter, so a missing delimiter returns gracefully instead of erroring. Default 0. |
if_not_found | Optional | What to return when the delimiter isn’t found — without it you get #N/A. |
Available in: Excel for Microsoft 365 and Excel for the web only. Excel 2021 and earlier show #NAME? — there the equivalent is MID(A2, FIND("@",A2)+1, LEN(A2)).
Grab the text after a delimiter
Emails in column A, domains wanted in column C. One argument pair does it:
| A | C | ||
|---|---|---|---|
| 1 | Domain | ||
| 2 | jane.doe@dfwexcel.com | dfwexcel.com | |
| 3 | m.alvarez@example.org | example.org | |
| 4 | kim@plano.k12.tx.us | plano.k12.tx.us |
Multi-character delimiters work too — split on a whole word:
And instance_num picks which occurrence to cut at:
Try it: interactive TEXTAFTER demo
Edit the text, pick a delimiter and an instance number. Try -1 on the path to pull out the file name.
Last-occurrence tricks and power moves
The negative instance number solves the classic “get the file name from the path” problem in one step:
Same trick for last names — everything after the last space survives middle names:
Sandwich TEXTAFTER inside TEXTBEFORE to cut a piece out of the middle — the quarter folder from the path:
Grab the file extension, then make missing delimiters harmless with if_not_found:
Errors & common pitfalls
#N/A — delimiter not found. The delimiter (or the nth instance) isn’t in the text. Pass if_not_found for a fallback value, or set match_end to 1.
#VALUE! — instance_num is 0 or out of range. Zero is never valid, and asking for more instances than the text could hold also fails.
#NAME? — older Excel. TEXTAFTER ships only in Excel for Microsoft 365 and Excel for the web. The legacy equivalent is =MID(A2, FIND("@",A2)+1, LEN(A2)).
Pitfall: case-sensitive by default. Searching for "q" skips "Q" until you set match_mode to 1.
Pitfall: numbers come back as text. Extract "4417" and it’s a string — SUM ignores it. Coerce with VALUE or -- before doing math: =--TEXTAFTER(A2, "no. ").
Practice workbook
Frequently asked questions
What's the difference between TEXTAFTER and TEXTBEFORE?
How do I get the text after the LAST occurrence of a character?
=TEXTAFTER(A2, "/", -1). That replaces the old SUBSTITUTE/CHAR(160)/FIND workaround that everyone used to copy off the internet.How do I extract text between two delimiters?
=TEXTBEFORE(TEXTAFTER(A2, "["), "]") returns whatever sits between the brackets.Why does TEXTAFTER return #N/A and how do I stop it?
=TEXTAFTER(A2, "@", , , , "") returns an empty string instead — or set match_end to 1.What's the TEXTAFTER equivalent in Excel 2021 and earlier?
=MID(A2, FIND("@", A2) + 1, LEN(A2)). It only handles the first occurrence; last-occurrence logic needs the SUBSTITUTE trick or a helper column.Is the extracted result text or a number?
-- if you need to add, average, or compare it as a number.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