extract text before, between, and after commas in text string

matthew101

New Member
Joined
Jun 22, 2018
Messages
13
I would greatly appreciate if anyone can help with a formula to extract the text before, between and after commas in the following:
5,6,31,3,1 or 14,3,24,2,14 there will be a max of 3 commas and 2 numbers separated by commas, so minimum of 9 characters and max of 14.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to Mr. Excel

Formula:

Code:
=SUBSTITUTE(A1,","," ")

UDF:

Code:
Function MakeCommasGo(sIn) As String
    MakeCommasGo = Replace(sIn, ",", " ")

End Function
 
Upvote 0
I would greatly appreciate if anyone can help with a formula to extract the text before, between and after commas in the following:
5,6,31,3,1 or 14,3,24,2,14 there will be a max of 3 commas and 2 numbers separated by commas, so minimum of 9 characters and max of 14.

Hi,

You didn't say How you want the numbers Extracted.
Also, your description does Not match your Samples as indicated by red above.

Do you want them in individual cells? If so, B1 formula copied down and across, results converted to Real Numbers for further comparison/math, let me know if you Don't want it converted (will remain as Text):


Book1
ABCDEF
15,6,31,3,1563131
214,3,24,2,1414324214
Sheet96
Cell Formulas
RangeFormula
B1=IFERROR(MID(SUBSTITUTE($A1,",",REPT(" ",50)),COLUMNS($B1:B1)*50-49,50)+0,"")
 
Last edited:
Upvote 0
Hi,

You didn't say How you want the numbers Extracted.
Also, your description does Not match your Samples as indicated by red above.

Do you want them in individual cells? If so, B1 formula copied down and across, results converted to Real Numbers for further comparison/math, let me know if you Don't want it converted (will remain as Text):

ABCDEF
15,6,31,3,1563131
214,3,24,2,1414324214

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet96

Worksheet Formulas
CellFormula
B1=IFERROR(MID(SUBSTITUTE($A1,",",REPT(" ",50)),COLUMNS($B1:B1)*50-49,50)+0,"")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Hi jtakw,
Thank you for your response.
I tried this solution and I am getting #NAME ? error. The cell containing the numbers separated by commas are ages. I would like to extract each age from the cell. Ages can be extracted to separate columns are fine or another method if more simple.
Thank you.
Matt
 
Upvote 0
Do you happen to be using an old version of Excel?
 
Upvote 0
You're welcome, glad it worked for you.
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,462
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top