What TEXTBEFORE does
TEXTBEFORE extracts everything that appears before a delimiter in a text string. It is useful for splitting email addresses, file names, codes, or imported strings when you only need the left-side portion.
Practical examples
Return the username from an email address
=TEXTBEFORE(A2,"@")
If A2 contains maya@example.com, the result is maya.
Return the text before the second dash
=TEXTBEFORE(A2,"-",2)
This is helpful when codes contain repeated separators and you need everything before a specific occurrence.
Common mistakes and notes
Missing delimiters return errors by default
If Excel cannot find the delimiter, TEXTBEFORE returns #N/A unless you supply if_not_found.
Delimiter matching is case-sensitive by default
If Red and red should be treated the same, set match_mode to 1.
instance_num cannot be zero
Use a positive number to search from the start or a negative number to search from the end. Zero returns a #VALUE! error.