Function · Split and regex

Excel TEXTBEFORE function

The Excel TEXTBEFORE function returns the text before a delimiter. Everything before the comma in Austin, TX 78701 is Austin.

Microsoft 365 and Excel 2024, including Excel for the web. Also in Google Sheets. Excel 2021 and earlier do not have it.

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

TEXTBEFORE
=TEXTBEFORE("Austin, TX 78701",",")

Arguments

NameRequiredWhat to pass
textRequiredThe text to cut.
delimiterRequiredThe mark to stop at. The mark itself is not included in the result.
instance_numOptionalWhich occurrence. 1, the default, is the first. A negative number counts from the end.
match_modeOptional0, the default, is case-sensitive. 1 ignores case.
match_endOptional0, the default, does not treat the end of the text as a delimiter. 1 does.
if_not_foundOptionalWhat to return when the delimiter is missing. If omitted, a miss is #N/A.

Examples

The city in Austin, TX 78701

=TEXTBEFORE(B1,",")

Result Austin

=TEXTBEFORE(B1,",")B2
Address
AB
1LineAustin, TX 78701
2CityAustin
A picture of the sheet, not a live calculator. The comma is the delimiter. The space after it stays with TX.

TEXTBEFORE returns the characters in front of a delimiter and drops the delimiter. In Austin, TX 78701 the first comma sits right after Austin, so the result is Austin. The space after the comma stays with the state. TEXTAFTER on the same comma would start at that space unless you include the space in the delimiter.

The third argument picks which match. 1 is the first comma. -1 is the last. A missing delimiter is #N/A unless you pass if_not_found. Excel 2021 does not have this function. LEFT and FIND are the older way to take the same slice.