In Excel 365 and 2021 this is a single function each way: =TEXTAFTER(A1,",") returns everything after the first comma and =TEXTBEFORE(A1,",") everything before it. Both take an instance number as the third argument, so =TEXTAFTER(A1,",",2) works from the second comma, and a negative number counts from the end — =TEXTAFTER(A1," ",-1) gets the last word.
On earlier versions you build it with SUBSTITUTE and REPT: =TRIM(RIGHT(SUBSTITUTE(A1,B1,REPT(" ",LEN(A1))),LEN(A1))) for the text after, and the same formula with LEFT in place of RIGHT for the text before. It works by padding each separator out to the full length of the string so the piece you want ends up isolated at one end, then trimming the spaces away.
Two things to know: TEXTBEFORE and TEXTAFTER return #N/A when the character isn’t found — add a fifth argument (if_not_found) to control that — and the padding method returns the whole string rather than an error, which is easy to miss.
In Excel, you can write formulas to extract text after or before a specific character. And in this tutorial, we will learn to write these formulas.
Extract Text After a Character
We need to use TRIM, RIGHT, SUBSTITUTE, REPT, and LEN in this formula. In the example below, each value has two words with a character in between.

=TRIM(RIGHT(SUBSTITUTE(A1,B1,REPT(" ",LEN(A1))),LEN(A1)))
=TRIM(RIGHT(SUBSTITUTE(original_text,character,REPT(" ",LEN(original_text))),LEN(original_text)))
To understand this formula, you need to split it into parts:
In the first part, we have SUBSTITUTE(A1,B1,REPT(" ",LEN(A1))). It’s the part of the formula that replaces the character (,) with a number of spaces equal to the length of the text.

You can see you have space between “Excel Champs” instead of the comma.
In the second part, =TRIM(RIGHT(“Excel Champs”,LEN(A1))), which extracts the text from the right side and then trims it to remove the extra spaces. If the character appears more than once, this formula returns the text after the last one.
Different Instances of Character?
While working with data, you might have multiple instances of the character, and the above formula might not help to deal with that. In this case, you need to use the below formula.

=IF(LEN(A1)-LEN(SUBSTITUTE(A1,B1,""))<C1,"",MID(SUBSTITUTE(A1,B1,"^^",C1),FIND("^^",SUBSTITUTE(A1,B1,"^^",C1))+2,LEN(A1)))
With this formula, you need to specify the character (B1) and the instance of that character (C1) after which you want to extract the text. If the text has fewer instances than C1, the formula returns a blank.

The above formula is complex but works like a wonder. The core of this formula is the SUBSTITUTE function, which gets the second or Nth instance of the character and replaces that instance with “^^”, which then helps to extract the text.
But you can also use the newer TEXTAFTER function (Excel for Microsoft 365 and Excel 2024), which has all the options to get the text after a character without a complex formula like the above.

You need to specify the character and the instance in the function.
=TEXTAFTER(A1,B1,C1)
Use a negative instance to count from the end of the text. For example, the following formula returns the text after the last comma:
=TEXTAFTER(A1,",",-1)

Extract Text Before a Character
You can use the formula below to get the text before a character.

It is the same formula we used to get the text after a character. Instead of RIGHT, you need to use LEFT to get the text from the left (before). It returns the text before the first instance of the character.
=TRIM(LEFT(SUBSTITUTE(A2,B2,REPT(" ",LEN(A2))),LEN(A2)))
This formula works the same way as the one above, so refer to that explanation to understand it.
Different Instances of Character
There are two ways to get the text before a specific instance of a character.
=IF(LEN(A2)-LEN(SUBSTITUTE(A2,B2,""))<C2,"",LEFT(SUBSTITUTE(A2,B2,"^^",C2),FIND("^^",SUBSTITUTE(A2,B2,"^^",C2))-1))
It can be used in any Excel version; you can specify the character and the instance to get the text.

But if you use Excel for Microsoft 365 or Excel 2024, you don’t need to use this complex formula. Instead, you can use the TEXTBEFORE function.

=TEXTBEFORE(A2,B2,C2)
Simple Formulas for the First Instance
If you only need the text before or after the first instance of the character, you can use a shorter formula with FIND. The following formula returns the text after the first comma:
=MID(A1,FIND(B1,A1)+1,LEN(A1))
And this one returns the text before the first comma:
=LEFT(A1,FIND(B1,A1)-1)
If the character is more than one character long, like “, ” (a comma and a space), replace +1 with +LEN(B1) in the first formula.
When the Character Is Not in the Text
Each method behaves differently when the cell doesn’t have the character:
- TRIM and SUBSTITUTE formulas: return the whole text.
- FIND formulas: return the #VALUE! error.
- TEXTAFTER and TEXTBEFORE: return the #N/A error, unless you use their if_not_found argument.
To return the whole text instead of an error with the FIND formula, wrap it in IFERROR:
=IFERROR(LEFT(A1,FIND(B1,A1)-1),A1)
And with TEXTBEFORE, use the last argument:
=TEXTBEFORE(A1,B1,1,0,0,A1)
Frequently Asked Questions
Are these formulas case-sensitive?
FIND and SUBSTITUTE are case-sensitive, so “X” and “x” are different characters for them. Use SEARCH instead of FIND for a case-insensitive match, or set the match_mode argument of TEXTAFTER and TEXTBEFORE to 1.
How do I get the text after the last space?
Use the TRIM and RIGHT formula from the top of this page with a space as the character, or use TEXTAFTER with -1 as the instance:
=TEXTAFTER(A1," ",-1)
Can I split the text into separate columns instead?
Yes. Use Data ➜ Text to Columns in any version, or the TEXTSPLIT function in Excel for Microsoft 365 and Excel 2024, which spills each part into its own cell.
Written by
Puneet Gogia
Microsoft MVP — Excel · Founder, Excel Champs
Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.