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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"]5,6,31,3,1[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]31[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]1[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]14,3,24,2,14[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]24[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]14[/TD]

</tbody>
Sheet96

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]B1[/TH]
[TD="align: left"]=IFERROR(MID(SUBSTITUTE($A1,",",REPT(" ",50)),COLUMNS($B1:B1)*50-49,50)+0,"")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

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,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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