ExcelExcel 2024+
TEXTBEFORE function in Excel
Returns text that occurs before a given character or string
=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])TEXTBEFORE syntax and parameters
Six arguments, two required.
- textstringRequired
- delimiterstringRequired
- instance_numanyOptional
- match_modeanyOptional
- match_endanyOptional
- if_not_foundanyOptional
TEXTBEFORE examples
Formulas you'll actually reuse.
The username part of an email — no FIND arithmetic needed:
=TEXTBEFORE(B2, "@")Result
"maria.lopez"Everything before the LAST hyphen — a negative instance counts from the end:
=TEXTBEFORE(A2, "-", -1)Result
"NYC-10422"
TEXTBEFORE in Google Sheets
No direct equivalent — here's the way around.
Try TEXTBEFORE in the playground
Edit the example — nothing to install.
Preloaded with the TEXTBEFORE formula from Example 1 — change anything and watch it respond.
Loading the editor…
TEXTBEFORE errors
What they mean — and the fixes.
#N/AThe delimiter wasn't found — pass if_not_found (the sixth argument) to return a fallback instead.
Related functions
More ways Excel gets this done.
- ARRAYTOTEXTReturns an array of text values from any specified rangeTextNo Google Sheets equivalent
- CHARReturns the character specified by the code numberTextGoogle Sheets
- CLEANRemoves all nonprintable characters from textTextGoogle Sheets
- CODEReturns a numeric code for the first character in a text stringTextGoogle Sheets
- CONCATCombines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments.TextGoogle Sheets
- CONCATENATEJoins several text items into one text itemTextGoogle Sheets