Splitting text with TEXTBEFORE and TEXTAFTER
Each email is a username, an @, then a domain. Pull the domain out into column B.
keyboard Typing formulas is easiest on a computer with a keyboard.
| A | B | C | |
|---|---|---|---|
| 1 | Domain | ||
| 2 | kofi.patel@greenleaf.example | ||
| 3 | jamal.novak@oakfield.example | ||
| 4 | isla@northgate.example | ||
| 5 | daniel@northgate.example | ||
| 6 | yusuf.dubois@oakfield.example | ||
| 7 | tariq.li@northgate.example | ||
| 8 | nadia.patel@brightway.example | ||
| 9 | quinn.evans@bluepeak.example | ||
| 10 | |||
| 11 | |||
| 12 | |||
| 13 |
How TEXTBEFORE and TEXTAFTER works
What do
TEXTBEFOREandTEXTAFTERdo?They split text at a character you choose, called the delimiter:
=TEXTBEFORE(A2,"@")gives everything before the @.=TEXTAFTER(A2,"@")gives everything after it.
The delimiter goes in double quotes. It can be more than one character, such as
", ".What if the character appears more than once?
Add a third part to say which one.
=TEXTAFTER(A2,".",-1)splits at the last dot, which gives the extension of a file name like report.final.xlsx. A positive number counts from the start, a negative one from the end.What if the character isn't there?
You get #N/A. Wrap it in
IFNA, or giveTEXTBEFOREits sixth part, the value to show instead.How did people do this before?
With
LEFT,MIDandFIND:=LEFT(A2,FIND("@",A2)-1). That still works everywhere, butTEXTBEFOREandTEXTAFTER(Excel 365 and Google Sheets) are much easier to read.
Know someone fighting with a spreadsheet? Send them this page.