Excel Tutorial
Excel tutorials, quizzes & AI guides — all levels
RSS
  • Online Excel Exercises
  • Training
  • Excel Tests
  • Sitemap
  • Premium Quizzes
  • Shop
  • My account

Mastering TEXTBEFORE and TEXTAFTER in Excel

Text functions
Reading time: 2 minutes
Views: 15,554

TEXTBEFORE and TEXTAFTER are new Excel 365 functions that allow you to extract text parts easily. These functions are easy to use and return complex extraction like what FlashFill can do.

They can efficiently extract names, first names, cities, zip codes, and addresses from text.

How to extract text with TEXTAFTER and TEXTBEFORE

Extract the first word of a string.

The TEXTBEFORE function returns text that occurs before a given character or string, like a space.

Extract the first word from a text

To extract the first word, write =TEXTBEFORE(A2," ").

Extract the first word of the cells

It is simple: you extract the text BEFORE the first delimiter.

Extract the first two words

TEXTBEFORE has a third argument that specifies how many words to extract.

To extract the name and surname, use =TEXTBEFORE(A2," ",2).

Extract Name and Firstname

Using LEFT and SEARCH, you would need a complex formula. So TEXTBEFORE is straightforward to use 😉

=LEFT(A2,SEARCH(” “,A2,SEARCH(” “,A2,1)+1))

The TEXTAFTER function

The TEXTAFTER function extracts text after the nth delimiter.

To return the address, postal code, and city, we must extract the string after the second “space”. So the formula is =TEXTAFTER(A2," ",2).

TEXTAFTER the second space

Use a negative value

TEXTAFTER and TEXTBEFORE allow negative values, and this is super useful. A negative value means you read your string from the right 😮👍

For instance, to extract the City name, that means the word after the last comma of the string, we will write the formula : TEXTAFTER(A2,",",-1)

Negative value to extract from the right of the string

How do you extract a substring in the middle?

To extract only the name, you combine both functions.

  • First, TEXTBEFORE extracts the first two words.
  • Then, TEXTAFTER extracts the last word from that result.

=TEXTAFTER(TEXTBEFORE(A2,” “,2),” “)

Extract the name only

Another example is how to extract the address only. You can do it with these steps.

  • Remove the name and surname using a space delimiter.
  • Remove the last two words using a comma delimiter.

=TEXTBEFORE(TEXTAFTER(A2,” “,2),”,”,-2)

Extract the address only

Related articles

  • Excel TEXTSPLIT Function: Easily Split Text into Parts
  • Splitting a text based on a pattern in Excel
  • Split Text on a Delimiter without Formula
  • Extract text with AI in Excel with FlashFill
  • Count Words in an Excel cell

Frédéric LE GUEN

delimiter, extract text, Flashfill

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Viewed Posts

  • Displaying Negative Numbers in Parentheses in Excel (310,065)
  • Top 10 Excel Functions You Must Know (232,001)
  • How to make automatic calendar in Excel (212,775)
  • Dash for a zero in Excel automatically (190,813)
  • Converting a Date from YYYYMMDD to DD/MM/YYYY in Excel (171,034)
image excel exercises
Excel Exercises
image excel quizzes
Excel Quizzes

Mastering TEXTBEFORE and TEXTAFTER in Excel

Reading time: 2 minutes
Views: 15,554

TEXTBEFORE and TEXTAFTER are new Excel 365 functions that allow you to extract text parts easily. These functions are easy to use and return complex extraction like what FlashFill can do.

They can efficiently extract names, first names, cities, zip codes, and addresses from text.

How to extract text with TEXTAFTER and TEXTBEFORE

Extract the first word of a string.

The TEXTBEFORE function returns text that occurs before a given character or string, like a space.

Extract the first word from a text

To extract the first word, write =TEXTBEFORE(A2," ").

Extract the first word of the cells

It is simple: you extract the text BEFORE the first delimiter.

Extract the first two words

TEXTBEFORE has a third argument that specifies how many words to extract.

To extract the name and surname, use =TEXTBEFORE(A2," ",2).

Extract Name and Firstname

Using LEFT and SEARCH, you would need a complex formula. So TEXTBEFORE is straightforward to use 😉

=LEFT(A2,SEARCH(” “,A2,SEARCH(” “,A2,1)+1))

The TEXTAFTER function

The TEXTAFTER function extracts text after the nth delimiter.

To return the address, postal code, and city, we must extract the string after the second “space”. So the formula is =TEXTAFTER(A2," ",2).

TEXTAFTER the second space

Use a negative value

TEXTAFTER and TEXTBEFORE allow negative values, and this is super useful. A negative value means you read your string from the right 😮👍

For instance, to extract the City name, that means the word after the last comma of the string, we will write the formula : TEXTAFTER(A2,",",-1)

Negative value to extract from the right of the string

How do you extract a substring in the middle?

To extract only the name, you combine both functions.

  • First, TEXTBEFORE extracts the first two words.
  • Then, TEXTAFTER extracts the last word from that result.

=TEXTAFTER(TEXTBEFORE(A2,” “,2),” “)

Extract the name only

Another example is how to extract the address only. You can do it with these steps.

  • Remove the name and surname using a space delimiter.
  • Remove the last two words using a comma delimiter.

=TEXTBEFORE(TEXTAFTER(A2,” “,2),”,”,-2)

Extract the address only

Related articles

  • Excel TEXTSPLIT Function: Easily Split Text into Parts
  • Splitting a text based on a pattern in Excel
  • Split Text on a Delimiter without Formula
  • Extract text with AI in Excel with FlashFill
  • Count Words in an Excel cell
Tags: delimiterextract textFlashfill

Frédéric LE GUEN

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Contact us
About me 
Privacy Policy

© 2022 – 2026 – excel-tutorial.com. All Rights Reserved.
Excel Tutorial is managed by majordome du net

Contact us
About me 
Privacy Policy

© 2022 – 2026 – excel-tutorial.com. All Rights Reserved.
Excel Tutorial is managed by majordome du net