TEXTBEFORE in Excel: what it does and how to use it
TEXTBEFORE returns everything that comes before a marker you name, such as a space, a dash or an at sign. Its twin, TEXTAFTER, returns everything on the other side.
Syntax
TEXTBEFORE(text, delimiter, [instance_num])
text
The value to cut up, usually a cell reference.
delimiter
The marker to stop at, in quotes. A space is " ", a dash is "-".
instance_num
Which occurrence of that marker to stop at. Leave it out and it stops at the first. Give it 2 and it stops at the second, so TEXTBEFORE("a-b-c","-",2) returns a-b. A negative number counts back from the end.
When to use it
Splitting one column into two. First name out of a full name, the part of a code before the dash, the piece of a reference before a slash.
What trips people up
It needs Microsoft 365. On older versions the same split is done with LEFT and FIND together: FIND locates the marker, LEFT takes everything up to it. That is why the older formula looks so much longer for the same job.
Set by your computer's language, not by the file. A frequent cause of a correct-looking formula being rejected.
Excel version
XLOOKUP, IFS, TEXTBEFORE and TEXTJOIN need Microsoft 365 or 2021; older versions return #NAME? instead. Choosing the older one switches every walkthrough to a formula that works there.