Grab the part of a string before or after a delimiter without counting characters. TEXTBEFORE and TEXTAFTER replace fiddly LEFT/RIGHT/FIND combinations with one clear function.
The example
An email split into user and domain.
| A | B | C | |
|---|---|---|---|
| 1 | Before @ | After @ | |
| 2 | ann@dfwexcel.com | ann | dfwexcel.com |
The formula
Text on either side of a delimiter:
How it works
Point at a delimiter and pick a side:
TEXTBEFORE(text, delim)returns everything before the delimiter;TEXTAFTEReverything after.- A third argument picks the Nth delimiter —
TEXTAFTER(A2, "/", 2)for the second slash. - Use a negative instance number to count from the end:
TEXTAFTER(A2, ".", -1)grabs the file extension. - Optional arguments handle “not found” and case sensitivity, so you can default gracefully.
Last segment trick: =TEXTAFTER(A2, "/", -1) returns the part after the last slash — perfect for filenames from a path. Before 365, this took a messy SUBSTITUTE/FIND combination.
Try it: interactive demo
Text + delimiter → before / after.
Variations
Nth delimiter
Second slash:
File extension
After the last dot:
If not found
Default value:
Pitfalls & errors
365 only. TEXTBEFORE/TEXTAFTER need Excel 365; older versions use LEFT/RIGHT with FIND.
Delimiter not found. By default a missing delimiter errors — supply the if_not_found argument to default instead.
Case sensitivity. Matching is case-insensitive unless you set the match-mode argument.
Practice workbook
Frequently asked questions
How do I get text before or after a character in Excel?
How do I get the text after the last delimiter?
What happens if the delimiter isn't found?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class