How to Get the Text Before a Character in Excel
TEXTBEFORE returns everything before a delimiter — carriers from tracking codes, cities from addresses, and more with instance numbers.
You will learn to
- Extract everything before a delimiter with TEXTBEFORE
- Use a comma as the delimiter for addresses
- Count delimiters from the end with a negative instance_num
How it works
=TEXTBEFORE(text, delimiter) returns everything in front of the delimiter: =TEXTBEFORE("UPS|1Z84F2","|") returns "UPS". It replaces the older =LEFT(A2,FIND("|",A2)-1) pattern and is much easier to read. It is available in Excel for Microsoft 365 and Excel 2024.
The third argument, instance_num, picks which delimiter to stop at. 2 means "before the second comma"; a negative number counts from the end, so -2 means "before the second-to-last comma" — perfect for stripping the city and state off a full address. If the delimiter is missing, TEXTBEFORE returns #N/A unless you supply if_not_found.
=TEXTBEFORE(A2,"|")