TopicsCheat sheetLessons
Lurndo › Excel › TEXTBEFORE and TEXTAFTER

Learning Excel: TEXTBEFORE and TEXTAFTER

Before and after a character

LEFT, SEARCH and a -1: it works, but Natalie frowns at all those brackets. Newer versions of Excel have two functions for it that say straight away what they do.

TEXTBEFORE and TEXTAFTER

TEXTBEFORE gives everything before a delimiter, TEXTAFTER everything after it. =TEXTBEFORE(C2,"@") gives sadie.devere, no counting needed.

Both exist in Excel 365 and Excel 2024 or later. In older versions you keep using LEFT and SEARCH.

G2
fx

=TEXTBEFORE(C2,"@")

ABCDEFG
1First nameLast nameEmailTableMobileAs typedResult
2SadieDe Veresadie.devere@mail.co.ukT01-COD07700 900 467 sadie de veresadie.devere
3JamesPearsonjames.pearson@yahoo.co.ukT01-STEAK07700 900 233JAMES PEARSON
4AmiraEl Idrissiamira@elidrissi.co.ukT02-VEG07700 900 654amira el idrissi
5LiamWaltersliam.w@gmail.comT02-COD07700 900 566Liam Walters
6FayeClarkfaye.clark@hotmail.co.ukT03-STEAK07700 900 456faye clark
7BillMossbill@moss-bakery.co.ukT03-VEG07700 900 321 BILL moss
8LibbyJenningslibby.jennings@yahoo.co.ukT04-COD07700 900 899libby jennings
9OwenVan Dykeowen.vandyke@mail.co.ukT04-STEAK07700 900 030owen VAN DYKE
10

Counting from the end

A third argument says which delimiter you mean: the first, the second, and so on. A negative number counts from the end.

=TEXTAFTER(C2,".",-1) gives everything after the last dot: uk.

G2
fx

=TEXTAFTER(C2,".",-1)

ABCDEFG
1First nameLast nameEmailTableMobileAs typedResult
2SadieDe Veresadie.devere@mail.co.ukT01-COD07700 900 467 sadie de vereuk
3JamesPearsonjames.pearson@yahoo.co.ukT01-STEAK07700 900 233JAMES PEARSON
4AmiraEl Idrissiamira@elidrissi.co.ukT02-VEG07700 900 654amira el idrissi
5LiamWaltersliam.w@gmail.comT02-COD07700 900 566Liam Walters
6FayeClarkfaye.clark@hotmail.co.ukT03-STEAK07700 900 456faye clark
7BillMossbill@moss-bakery.co.ukT03-VEG07700 900 321 BILL moss
8LibbyJenningslibby.jennings@yahoo.co.ukT04-COD07700 900 899libby jennings
9OwenVan Dykeowen.vandyke@mail.co.ukT04-STEAK07700 900 030owen VAN DYKE
10

Try it yourself

In G2, put the domain of Sadie's address, everything after the @.

ABCDEFGH
1First nameLast nameEmailTableMobileAs typedResult
2SadieDe Veresadie.devere@mail.co.ukT01-COD07700 900 467 sadie de vere
3JamesPearsonjames.pearson@yahoo.co.ukT01-STEAK07700 900 233JAMES PEARSON
4AmiraEl Idrissiamira@elidrissi.co.ukT02-VEG07700 900 654amira el idrissi
5LiamWaltersliam.w@gmail.comT02-COD07700 900 566Liam Walters
6FayeClarkfaye.clark@hotmail.co.ukT03-STEAK07700 900 456faye clark
7BillMossbill@moss-bakery.co.ukT03-VEG07700 900 321 BILL moss
8LibbyJenningslibby.jennings@yahoo.co.ukT04-COD07700 900 899libby jennings
9OwenVan Dykeowen.vandyke@mail.co.ukT04-STEAK07700 900 030owen VAN DYKE
10
G2

Ready for more?

The full lesson has 5 exercises, from easy to challenging, with hints, points and a streak you can build.

Start the lesson
← PreviousCutting from the middleNext →Sticking text together

SQL

  • Topics
  • All lessons
  • Cheat sheet

Excel

  • Topics
  • All lessons
  • Shortcuts

HTML & CSS

  • About the course
  • All lessons

Lurndo

  • Dashboard
  • Leaderboard
  • Premium
  • Account
  • Privacy
Nederlands