Back to functions
Text2026-06-130 related articles

TEXTBEFORE Function in Excel

Return the text that appears before a chosen delimiter.

Syntax

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

Arguments

text

Required

The text value you want Excel to search within.

delimiter

Required

The text that marks where the returned result should stop.

instance_num

Optional

Which occurrence of the delimiter Excel should use. Negative numbers search from the end.

match_mode

Optional

Use 1 for a case-insensitive match. The default 0 is case-sensitive.

match_end

Optional

Use 1 to treat the end of the text as a delimiter.

if_not_found

Optional

The value to return if the delimiter is not found. The default behavior returns

What it returns

Returns the portion of text that appears before the selected delimiter.

What TEXTBEFORE does

TEXTBEFORE extracts everything that appears before a delimiter in a text string. It is useful for splitting email addresses, file names, codes, or imported strings when you only need the left-side portion.

Practical examples

Return the username from an email address

=TEXTBEFORE(A2,"@")

If A2 contains maya@example.com, the result is maya.

Return the text before the second dash

=TEXTBEFORE(A2,"-",2)

This is helpful when codes contain repeated separators and you need everything before a specific occurrence.

Common mistakes and notes

Missing delimiters return errors by default

If Excel cannot find the delimiter, TEXTBEFORE returns #N/A unless you supply if_not_found.

Delimiter matching is case-sensitive by default

If Red and red should be treated the same, set match_mode to 1.

instance_num cannot be zero

Use a positive number to search from the start or a negative number to search from the end. Zero returns a #VALUE! error.

Related functions

Official documentation