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])
| Argument | What it is |
|---|---|
| text | The full text. |
| delimiter | What marks the cut, such as ", " or "@". |
| instance_numoptional | Which 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.
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.
In B2, extract the last name: everything before the comma.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Full name | Last name | First name | |
| 2 | Hernández, Carmen | |||
| 3 | Ortiz, Jorge Luis | |||
| 4 | Ramírez, Lucía | |||
| 5 | De la Cruz, Andrés | |||
| 6 | Vega, 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.