TEXTBEFORE Function
Returns the text that comes before a delimiter.
Category
Text
Available in
Microsoft 365, Excel 2024
Returns
Text
Overview
TEXTBEFORE returns everything before a character or word you specify — the part of an email before the @, a first name before the space.
It replaces the old LEFT + FIND combination, and can count from the end with a negative instance number.
Syntax
=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])
Arguments
| Argument | Required? | What it does |
|---|---|---|
| text | Yes | The text to search. |
| delimiter | Yes | The character or text to stop at. |
| instance_num | Optional | Which occurrence to use. 1 = first (default); -1 = last. |
| match_mode | Optional | 1 ignores case. Default 0. |
| match_end | Optional | 1 treats the end of the text as a delimiter. Default 0. |
| if_not_found | Optional | What to return when the delimiter isn't found. Default #N/A. |
Examples
Example 1 — Username from an email
Take everything before the @.
B2fx=TEXTBEFORE(A2, "@")
| A | B | |
|---|---|---|
| 1 | Username | |
| 2 | ana.lopez@northstar.com | ana.lopez |
| 3 | ben.cho@northstar.com | ben.cho |
| 4 | cara@partner.ca | cara |
=TEXTBEFORE(A2, "@") Explain
Example 2 — Everything before the last dash
Drop the colour code from the end of each SKU.
B2fx=TEXTBEFORE(A2, "-", -1)
| A | B | |
|---|---|---|
| 1 | SKU | Base SKU |
| 2 | NS-1042-BLU | NS-1042 |
| 3 | NS-2210-RED | NS-2210 |
| 4 | NS-0087-GRN | NS-0087 |
=TEXTBEFORE(A2, "-", -1) Explain
Common mistakes
- #N/A when there's no delimiter. Use the last argument: =TEXTBEFORE(A2, " ", , , , A2) returns the whole text when there's no space.
Notes

Author
Kyle Stott
Certified Microsoft Excel Expert
Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.