TEXTBEFORE Function in Excel: Text Before a Delimiter

TEXTBEFORE Function in Excel: Text Before a Delimiter featured illustration

πŸ“Ž This article includes 1 downloadable practice file ↓

⏱ 2 min readUpdated 12 October 2026

TextLevel: IntermediateAvailable in: Excel 365 / 2021+

In this article
  1. Syntax
  2. Examples
  3. Example 1
  4. Example 2
  5. Example 3
  6. TEXTBEFORE in practice
  7. Where you will use it
  8. Worked example
  9. Mistakes people make
  10. Related functions
  11. Continue learning

TEXTBEFORE returns everything before a delimiter; TEXTAFTER everything after. They replace most LEFT/FIND and MID/FIND combinations.

Advertisement

Syntax

=TEXTBEFORE(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])
Argument What it means
instance_num Which occurrence; negative counts from the end.
if_not_found Result when the delimiter is missing.

Examples

Example 1

=TEXTBEFORE(A2, "@")

Username from an email.

Example 2

=TEXTBEFORE(A2, " ", -1)

Everything except the last word.

Example 3

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

Whole text if there is no dash.

TEXTBEFORE in practice

Where you will use it

  • Name from an email
  • Code before a dash
  • First word of a sentence

Worked example

TextFormulaResult
[email protected]=TEXTBEFORE(A2,{"@","-"," "})ravi
INV-2026-145=TEXTBEFORE(A3,{"@","-"," "})INV
Masala tea 250g=TEXTBEFORE(A4,{"@","-"," "})Masala

Results calculated in Excel.

Mistakes people make

MistakeWhat to do instead
Missing delimiterUse if_not_found
Casematch_mode 1 makes it case-insensitive

TEXTAFTER Β· TEXTSPLIT Β· LEFT

πŸ“š Part of the free Excel course: Beginner β†’ Expert Β· Try it in the Formula Lab or ask the AI Helper.

⚑ Interactive Practice Lab & Formula Tester:

Test formulas dynamically in our web formula laboratory or download the companion Excel workbook.

πŸ“Ž Practice files for this article

  • πŸ“—
    Practice workbook: Text & cleaning24 tasks on realistic sales data β€” type your formula, the Check column turns green when it is right. Answers sheet included.
    ⬇ XLSX Β· 35 KB

Free to use for learning. Files with macros (.bas) are plain text β€” import them with Alt+F11 β†’ File β†’ Import File, and always test on a copy.

✨ Ask AI about this article

Stuck on a step? Ask a question and the AI answers using this article.

Free Β· AI can be wrong

Leave a Reply

Your email address will not be published. Required fields are marked *