TEXTBEFORE in Excel: get the text before a character
Microsoft 365 and Excel 2024.
Syntax
=TEXTBEFORE(text, delimiter, [instance], [match_mode], [match_end], [if_not_found])
Before the first @
=TEXTBEFORE(A2,"@")
asha@mail.in → asha
First name from a full name
=TEXTBEFORE(A2," ")
Before the 2nd or the last occurrence
=TEXTBEFORE(A2,"-",2) =TEXTBEFORE(A2,"-",-1)
INV-2026-045 → INV-2026 with either (a negative number counts from the end).
When the delimiter isn’t there
You get #N/A. Return the whole text instead:
=TEXTBEFORE(A2," ",,,,A2)
Ignore upper/lower case
Set match_mode to 1: =TEXTBEFORE(A2,"ref",,1)
Older Excel
=LEFT(A2,FIND("@",A2)-1)
The other half: TEXTAFTER · Split into many columns: TEXTSPLIT