Excel Function

Excel TEXTBEFORE function

Extract everything before a specific character or word — one formula, no nesting required.

TEXTBEFORE returns the text that appears before a specified delimiter. It replaces the old approach of nesting LEFT with FIND, which was error-prone and hard to read.

Syntax

TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])
ArgumentWhat it means
text requiredThe text string to extract from.
delimiter requiredThe character or string to search for.
instance_num optionalWhich occurrence to use. Default is 1 (first). Use -1 for the last occurrence.
match_mode optional0 = case-sensitive (default), 1 = case-insensitive.
if_not_found optionalWhat to return if delimiter isn't found. Defaults to #N/A.

Examples

Extract first name from full name

=TEXTBEFORE(A2, " ")

If A2 contains "Sarah Johnson", this returns "Sarah".

Extract domain from email address

=TEXTBEFORE(A2, "@")

If A2 contains "sarah@example.com", this returns "sarah".

Extract everything before the last comma

=TEXTBEFORE(A2, ",", -1)

Use -1 as instance_num to count from the end. Useful for addresses where the last comma separates city from country.

💡 The old way vs the new way

Before TEXTBEFORE, extracting text before a space required: =LEFT(A2, FIND(" ",A2)-1) — and crashed with an error if no space existed. TEXTBEFORE handles missing delimiters gracefully via the if_not_found argument.

What is the difference between TEXTBEFORE and TEXTAFTER?
TEXTBEFORE returns everything before the delimiter. TEXTAFTER returns everything after it. They are designed to work together for splitting text cleanly.
What version of Excel supports TEXTBEFORE?
Excel 365 and Excel for the web only. Not available in Excel 2021, 2019, or earlier.

Practice TEXTBEFORE for real

Type it in a live spreadsheet, get instant feedback. No videos, no downloads.

Start practising free →