In Excel: use =TEXTBEFORE(text, delimiter) or =TEXTAFTER(text, delimiter) — they replace the whole LEFT-with-FIND idiom with one readable call. Function availability: TEXTBEFORE: Excel 2024+. These are Microsoft's version markers; earlier perpetual releases do not include these functions. Check the actual product and update channel before using the formula. A marker does not establish an identical Web/Mac workflow or Google Sheets support.
On this page8
Syntax
Arguments
| Argument | required / optional | Description |
|---|---|---|
text | required | The text to split. |
delimiter | required | The marker to split at. |
instance_num | optional | Which occurrence to use. Negative counts from the end. |
if_not_found | optional | What to return when the delimiter is absent, instead of #N/A. |
Related functions
Function availability: TEXTBEFORE: Excel 2024+. These are Microsoft's version markers; earlier perpetual releases do not include these functions. Check the actual product and update channel before using the formula. A marker does not establish an identical Web/Mac workflow or Google Sheets support.
Type =TEXTBEFORE( or =TEXTAFTER( and select the cell to split.
Add a comma and the delimiter in quotes.
Add an instance number if the delimiter repeats — negative counts from the end.
Add the if_not_found argument last so rows without the delimiter do not return #N/A.
What this does
These two return everything before or after a delimiter. They exist to retire one of the most-copied formulas in spreadsheet history: =LEFT(A2, FIND("@", A2)-1), with its off-by-one that everybody gets wrong at least once. The instance argument picks which occurrence to split at, and a negative value counts from the end — so getting the file extension after the LAST dot is one argument rather than a nested reversal trick. The if_not_found argument replaces the IFERROR wrapper the old idiom always needed. Requires Excel 365. Keep the inputs visible and clearly labelled and the whole thing stays auditable — anyone who opens the file later, including you, can see at a glance exactly what feeds the result and change one assumption without hunting through the formula. The difference between a quick fix and a sheet you can trust is the extra minute you spend validating “textbefore function excel”. Start on a copy or a tiny sample, keep the affected formula visible, and compare the result with the outcome you expected before you touch the real workbook. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. The point is a calculation you can defend to a CFO or an auditor, but the practical win is that someone else can open the file and understand what happened without asking you.
A worked example
Splitting an email: =TEXTBEFORE(A2, "@") returns the username and =TEXTAFTER(A2, "@") the domain. A file extension after the final dot: =TEXTAFTER(B2, ".", -1). Handling missing delimiters gracefully: =TEXTBEFORE(A2, "@", 1, 0, 0, A2) returns the original value instead of #N/A. TEXTBEFORE and TEXTAFTER retire the LEFT-with-FIND idiom and its permanent off-by-one, which is worth the version requirement alone. Check the referenced cells, argument order and result type in your workbook. Start with the worked example before changing an input, then compare the changed result with the calculation you expected. An error value or a result of a different type is a reason to inspect the inputs and arguments.
In Google Sheets
Function availability: TEXTBEFORE: Excel 2024+. These are Microsoft's version markers; earlier perpetual releases do not include these functions. Check the actual product and update channel before using the formula. A marker does not establish an identical Web/Mac workflow or Google Sheets support. The aim was to get you unstuck fast and leave you a little more capable than a copy-paste would. The answer is at the top and the detail above shows why it holds — so the next time a colleague asks, you can answer without reaching for search. For “textbefore function excel”, keep the input cells and the result visible while you check the formula in Excel. Follow the worked example and change one input at a time. The steps explain the workbook calculation; this page does not run a live calculator for that task.
Common mistakes
- Using them in Excel 2021 or earlier, where they return
#NAME?— theLEFT/FIND idiom is still the portable option. - Omitting if_not_found, so any row missing the delimiter returns
#N/Aand breaks the column. - Forgetting that the delimiter is case-sensitive by default; the match_mode argument relaxes it.
Frequently asked questions
How do I get the text before a character?
=TEXTBEFORE(A2, "-"). In older Excel, =LEFT(A2, FIND("-", A2)-1).
How do I split at the LAST occurrence?
Pass -1 as the instance argument: =TEXTAFTER(A2, ".", -1) returns everything after the final dot.
Which versions have these?
Microsoft 365 and Excel for the web. Perpetual versions up to 2021 do not.
Which Excel release does this formula require?
Function availability: TEXTBEFORE: Excel 2024+. These are Microsoft's version markers; earlier perpetual releases do not include these functions. Check the actual product and update channel before using the formula. A marker does not establish an identical Web/Mac workflow or Google Sheets support.