Skip to content
ExcelExcel 2024+

TEXTBEFORE function in Excel

Returns text that occurs before a given character or string

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

TEXTBEFORE syntax and parameters

Six arguments, two required.

  • textstringRequired
  • delimiterstringRequired
  • instance_numanyOptional
  • match_modeanyOptional
  • match_endanyOptional
  • if_not_foundanyOptional

TEXTBEFORE examples

Formulas you'll actually reuse.

  1. The username part of an email — no FIND arithmetic needed:

    =TEXTBEFORE(B2, "@")

    Result"maria.lopez"

  2. Everything before the LAST hyphen — a negative instance counts from the end:

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

    Result"NYC-10422"

TEXTBEFORE in Google Sheets

No direct equivalent — here's the way around.

Try TEXTBEFORE in the playground

Edit the example — nothing to install.

Preloaded with the TEXTBEFORE formula from Example 1 — change anything and watch it respond.

Loading the editor…

TEXTBEFORE errors

What they mean — and the fixes.

  • #N/A

    The delimiter wasn't found — pass if_not_found (the sixth argument) to return a fallback instead.