Spreadsheet Practice

TEXTBEFORE function

Quick answer

TEXTBEFORE returns everything before a delimiter you name, such as the username before the @ in an email or the first name before a space.

Syntax
=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])
Most common use
=TEXTBEFORE(A2,"@") returns maya.chen (The username before the @)

It needs no position math, and it can count from the end to split at the last delimiter instead of the first.

Available in
Excel 2024 and Microsoft 365
Category
Text functions
Returns
The text before the chosen delimiter.

Syntax

=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])

ArgumentRequired?What it is
textRequiredThe text or cell to split.
delimiterRequiredThe character or text to split at.
instance_numOptionalWhich delimiter to use: 1 for the first (default), 2 for the second, -1 for the last.
match_modeOptional0 for a case-sensitive match (default), 1 to ignore case.
match_endOptional1 treats the end of the text as a delimiter, so text without one comes back whole. The default is 0.
if_not_foundOptionalWhat to return when the delimiter isn't there, instead of #N/A.

Examples

Each result below is calculated from the sample sheet by our formula engine, the same one that grades the practice.

CellFormulaResultWhat it shows
D2=TEXTBEFORE(A2,"@")maya.chenThe username before the @
D3=TEXTBEFORE(C3," ",-1)Raj KumarEverything before the last space
D4=TEXTBEFORE(C4," ",,,,C4)CherNo space at all, so if_not_found returns the whole name instead of #N/A

Try it live

This is the sample sheet. Change any number or text, or edit a formula, and the results update.

Show the sample data as a table
EmailFileFull nameResult
maya.chen@acme.comQ3_report_final.xlsxMaya Chenmaya.chen
raj@globex.iobudget_2026.csvRaj Kumar PatelRaj Kumar
lee.wong@initech.netnotes.txtCherCher

Practice TEXTBEFORE

From lesson 21, TEXTBEFORE, TEXTAFTER & FIND. Graded instantly, then re-checked on changed data.

Username

In B2, return everything before the @. Fill down to B6.

Common mistakes

What you seeWhy, and how to fix it
#N/AThe delimiter isn't in the text. Set if_not_found: =TEXTBEFORE(A2," ",,,,A2) returns the whole text instead.
#NAME?TEXTBEFORE is only in Excel 2024 and Microsoft 365. In older versions, use =LEFT(A2,FIND("@",A2)-1).
The split is missed because of caseThe match is case-sensitive by default, so "X" won't split at "x". Set match_mode to 1.

Tips

  • Get the text between two delimiters by nesting: =TEXTBEFORE(TEXTAFTER(A2,"("),")").

Questions

How do I get the text before a character in Excel?

In Excel 2024 or Microsoft 365, use =TEXTBEFORE(A2,"-"). In older versions, use =LEFT(A2,FIND("-",A2)-1).

How do I extract the first name from a full name?

=TEXTBEFORE(A2," ") returns everything before the first space. Add if_not_found, =TEXTBEFORE(A2," ",,,,A2), so single-word names come back whole.

Lessons that use TEXTBEFORE

Answers that use TEXTBEFORE

In other languages

TEXTBEFORE is TEXTOANTES in Spanish Excel and TEXTVOR in German Excel. Each page has the syntax with semicolons, the examples and the exercise in that language. For other functions and languages, use the Function Translator.

Updated Checked by running: every formula on this page was run by our formula engine on .