How to Extract Text between Commas

This post will guide you how to extract text between commas in excel.

Before we talked that how to extract text between brackets using a formula with MID and SEARCH functions. And this post will extract text between commas instead of brackets. The biggest difference is that the brackets have the left and right, but the comma is not. So you can’t use the similar formula for commas.

To extract text between commas in Cell B1, you can use the following formula based on the SUBSTITUTE function, the MID function and the REPT function.

=SUBSTITUTE(MID(SUBSTITUTE("," & B1&REPT(" ",6), "," , REPT(",",255)),2*255,255), ",", " ")

Let’s see how this formula works:

=”,” & B1&REPT(” “,6)

extract text between commas 1

The REPT function will repeat empty string 6 times.

The concatenation operator (&) will join together one comma and text string in Cell B1 and another empty text string returned by REPT function to build a new text string. It will go into SUBSTITUTE function as its Text argument. This formula returns as a new text string like this:



= SUBSTITUTE(“,” & B1&REPT(” “,6), “,” , REPT(“,”,255))

The second argument of SUBSTITUTE function is set to a comma character as its Old_text argument.

The new_text value will use the result returned by the REPT function, it will repeat a comma character 255 times.

So this formula will replace all commas with new_text 255 commas in new text string.  The returned string is like this:

,,,,,,,,,,,,,,,,,excel,,,,,,,,,,,,,,,,,word,,,,,,,,,,,,,,,ppt        (255 commas between each word)


= MID(SUBSTITUTE(“,” & B1&REPT(” “,6), “,” , REPT(“,”,255)),2*255,255)

extract text between commas 3

This MID function will extract 255 characters from a text string (returned by the above SUBSTITUTE function) at a specific position 2*255.  So it returns like this:



=SUBSTITUTE(MID(SUBSTITUTE(“,” & B1&REPT(” “,6), “,” , REPT(“,”,255)),2*255,255),”,”,””)

extract text between commas 4

This formula will use a text string returned by the MID function as its Text argument and then replace all commas with the empty text string. So the last returned result is text that you want to extract.

Related Formulas

  • Extract Text between Parentheses
    If you want to extract text between parentheses in a cell, then you can use the search function within the MID function to create a new excel formula…
  • Extract Text between Brackets
    If you want to extract text between brackets in a cell, you need to create a formula based on the SEARCH function and the MID function….
  • Check If Cell Contains All Values from Range
    If you want to check if a cell contains all values in a list, you can use a combination of the SEARCH function, the SUMPRODUCT function, the ISNUMBER function and COUNTA function…

Related Functions

  • Excel Substitute function
    The Excel SUBSTITUTE function replaces a new text string for an old text string in a text string. The syntax of the SUBSTITUTE function is as below:= SUBSTITUTE  (text, old_text, new_text,[instance_num])….
  • Excel MID function
    The Excel MID function returns a substring from a text string at the position that you specify.The syntax of the MID function is as below:= MID (text, start_num, num_chars)…
  • Excel REPT function
    The Excel REPT function repeats a text string a specified number of times.The REPT function is a build-in function in Microsoft Excel and it is categorized as a Text Function.The syntax of the REPT function is as below:= REPT  (text, number_times)….
Related Posts

Find and Replace Multiple Values
find replace multiple values5

This post will guide you how to find and replace multiple values at once with VBA macro or using formula  in Excel. How do I make multiple find and replace in Excel. Suppose that you have a few cells containing ...

Extract Last Two Words From Multiple Cells
extract last word from multiple cells1

Just assume that you have a few cells containing values/words and you want to extract the last two words from each cell into another separate cell; then you might think that it's not a big deal; because you would prefer ...

Extract Multiple Lines From A Cell

Suppose that you have listed some text in a single cell which is separated by the line break(you can do it by pressing ALT + ENTER after entering the text), and now you want to extract multiple lines of text ...

How to Remove All Asterisk Characters from Cells in Excel
How to Remove All Asterisk Characters7

Sometimes when we opening an excel spreadsheet to check data, we may notice that there are some asterisks exist in texts for security or other reasons. If you feel these special characters are invalid you can remove them from cells. ...

How to Convert Date Format from Dot MM.DD.YYYY to Slash MM/DD/YYYY in Excel
Convert Date Format from Dot to Slash 6

We often enter dates in excel tables, and we can enter current date by quickly press ‘Ctrl+;’ simultaneously. If in some cases we enter a date format that is not what we want, we have to switch the date format ...

How to Remove Quotes for Text or Strings in Excel
How to Remove Quotes 8

When we importing data from other source into Excel we may import quotes or quotations from initial file. And we want to remove these quotes from current file, if we remove them one by one it needs a lot of ...

How to Remove Specific Character from Text Cell in Excel
remove specific character from text string6

This post will guide you how to remove a specific character from text cell in Excel. How do I remove certain character from a cell with a formula in Excel 2013/2016. Remove Specific Character Using Find and Replace function Remove ...

How to Count Comma Separated Value in One Cell in Excel
count value separated by comma2

This post will guide you how to count values in a single cell separated by commas with a formula in Excel. How do I count comma separated values in one cell in Excel 2013/2016. Is it possible to have a ...

How to Count the Number of Letters or Numbers separately in a Cell in Excel
count number of letters3

This post will guide you how to count the number of a given character in a cell in Excel. How do I count only numbers within a single cell excluding all letters and other characters with a formula in Excel. ...

How to Remove the First/Last Word from Text string in Cell
remove first last word in cell2

This post will guide you how to remove the first and the last word from a text string in cells in Excel. How do I use a formula to remove first and last word of a text string in Excel. ...