Excel functions / Text

TEXTBEFORE & TEXTAFTER

Return the text before or after a delimiter, such as a space, comma or @ sign.

Syntax=TEXTBEFORE(text, delimiter, [instance_num]) =TEXTAFTER(text, delimiter, [instance_num])

Arguments

textThe text to split.
delimiterThe character or text to split at.
instance_numOptional. Which occurrence to use. Negative numbers count from the end, so -1 is the last.

How it works

These two functions make splitting text easy. =TEXTBEFORE(B2,"@") returns the part of an email before the @, and =TEXTAFTER(B2,"@") returns the domain.

The instance number picks which delimiter to split at when there are several. They are available in Microsoft 365 and Excel for the web.

Example

D2=TEXTAFTER(B2,"@")
ABCD
1NameEmail
2Nina Shahnina.shah@example.comexample.com
3Omar Reidomar@example.com
4Mary Ann Leemary.lee@example.com
5

Result: example.com. Everything after the @ sign: the email domain.

Tips

Practise TEXTBEFORE & TEXTAFTER

Try it yourself in a real spreadsheet, with instant feedback on every answer.

Start the exercise

Related