Excel TEXTBEFORE function

Returns the text that comes before a delimiter. In Spanish Excel it is called TEXTOANTES.

Syntax

English Excel

=TEXTBEFORE(text, delimiter, [instance_num])

Spanish Excel (Mexico)

=TEXTOANTES(texto, delimitador, [núm_instancia])

Spanish Excel (Spain, Latin America)

=TEXTOANTES(texto; delimitador; [núm_instancia])

ArgumentWhat it is
textThe full text.
delimiterWhat marks the cut, such as ", " or "@".
instance_numoptionalWhich occurrence to use; negative counts from the end.

Example

TEXTBEFORE(text, delimiter) returns what comes before the delimiter and TEXTAFTER what comes after it. They replace long combinations of LEFT, FIND and MID. Excel 365 only.

=TEXTBEFORE(A2,", ")

Common mistake

Excel 365 only. If the delimiter is not found it returns #N/A; the sixth argument chooses what to show instead.

About Ads

This site uses Google AdSense to display ads. These ads help us keep WebHerramientas completely free. Ads are managed by Google and meet strict security and privacy standards.

Advertising
Loading ad...

Ads help us keep WebHerramientas free for everyone

Practice TEXTBEFORE

Type the formula in the sheet and check it instantly. Spanish or English function names both work. See all lessons

TEXTBEFORE and TEXTAFTER

TEXTBEFORE(text, delimiter) returns what comes before the delimiter and TEXTAFTER what comes after it. They replace long combinations of LEFT, FIND and MID. Excel 365 only.

Step 1/2

In B2, extract the last name: everything before the comma.

B2
ABCD
1Full nameLast nameFirst name
2Hernández, Carmen
3Ortiz, Jorge Luis
4Ramírez, Lucía
5De la Cruz, Andrés
6Vega, Paola
7

Tip: while typing, click a cell or drag across several to insert their reference. F4 anchors the reference with $.

Frequently asked questions

What is TEXTBEFORE called in Spanish?
In Spanish Excel it is TEXTOANTES. The formula =TEXTBEFORE(A2,", ") is written =TEXTOANTES(A2;", ") (or with commas in Mexico).
Why does TEXTBEFORE use semicolons in some Excel versions?
It depends on regional settings. Where the comma is the decimal mark (Spain, much of South America), Excel separates arguments with semicolons. English Excel and Mexican Spanish Excel use commas.
What is the most common TEXTBEFORE mistake?
Excel 365 only. If the delimiter is not found it returns #N/A; the sixth argument chooses what to show instead.