Excel Formula - How to extract values between commas?

YSWOO

New Member
Joined
Dec 7, 2020
Messages
10
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
  2. Mobile
example

RANGE (A1) : AA, BB, CC, DD, EE, FF, GG, HH

TARGET
(B1) : AA
(B2) : BB
(B3) : CC
(B4) : DD
(B5) : EE
(B6) : FF
(B7) : GG
(B8) : HH

I made second part, but after second, i do not know how to make it...
=MID(A1,FIND(",",A1)+1,FIND(",",A1,FIND(",",A1)+1)-(FIND(",",A1)+1))

please help me to do..
 
I took a my mistake!

AA, BB, CC... -> That is sample for looking convinient.

Actually, the Original Text is random. Just all text is located between commas.

It could be like AAA, BB, CCC,DDDDDD,EEEEEEEEEE,F.

Could you help me to figure it out?

Thanks
I think the best approach is using VBA. Maybe convert code by Doccfm0q to become UDF
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Since I'm not sure how you are going to present the output. I just created a UDF (User Defined Function)

VBA Code:
Function GetData(rng As Range, Pos As Long, Optional Delimiter As String = ",") As String

Dim ArryStrS() As String

ArryStr = Split(rng, Delimiter)
GetData = Trim(ArryStr(Pos - 1))

End Function

Say your Data is in A1 = AAA, BB, CCC,DDDDDD,EEEEEEEEEE,F

If you want to get BB, then the formula you want to type in any cell is =GetData(A1,2) for data in position 2. If the delimiter is : (colon), just type =GetData(A1,2,":")
 
Upvote 0
Thanks for your answer!!!

Awesome!!!

But, If I change "," comma to other like "@" ?
 
Upvote 0
Thanks for your answer!!!

Awesome!!!

But, If I change "," comma to other like "@" ?
As stated, comma is default value. You can put @ in formula like sample provided before =GetData(A1,2,"@")
 
Upvote 0
Try this formula
VBA Code:
=FILTERXML("<AllText><Num>"&SUBSTITUTE(A1,",","</Num><Num>")&"</Num></AllText>","//Num")
I want to use this formula

that is awesome!!

but the thing is that if i use not ",", but "@", How to change that?
 
Upvote 0
Test.xlsx
AB
1AA, BB, CC, DD, EE, FF, GG, HHAAA, BB, CCC,DDDDDD,EEEEEEEEEE,F.AA
2BB
3CC
4DD
5EE
6FF
7GG
8HHAAA
9BB
10CCC
11DDDDDD
12EEEEEEEEEE
13F.
14 
15 
16 
17 
18 
bb
Cell Formulas
RangeFormula
B1:B18B1=IFERROR(TRIM(MID($A$1,FIND("|",SUBSTITUTE(","&$A$1&",",",","|",ROW()-ROW($B$1)+1)),FIND("|",SUBSTITUTE(" "&$A$1&",",",","|",ROW()-ROW($B$1)+1))-FIND("|",SUBSTITUTE(","&$A$1&",",",","|",ROW()-ROW($B$1)+1))-1)),"")
 
Upvote 0
In case you want to try a little macro.
Code:
Sub Split_At_Comma()
    Cells(1, 2).Resize(UBound(Split(Cells(1, 1), ",")) + 1) = Application.Transpose(Split(Cells(1, 1), ","))
End Sub
 
Upvote 0
What about this shorter one?

20 12 08.xlsm
AB
1AAA, BB, CCC,DDDDDD,EEEEEEEEEE,FAAA
2BB
3CCC
4DDDDDD
5EEEEEEEEEE
6F
7 
Split Cell
Cell Formulas
RangeFormula
B1:B7B1=IFERROR(TRIM(RIGHT(SUBSTITUTE(LEFT(A$1,FIND("#",SUBSTITUTE(A$1&",",",","#",ROWS(B$1:B1)))-1),",",REPT(" ",99)),99)),"")



.. or with your question about using @ instead:

20 12 08.xlsm
AB
1AAA@ BB@ CCC@DDDDDD@EEEEEEEEEE@FAAA
2BB
3CCC
4DDDDDD
5EEEEEEEEEE
6F
7 
Split Cell (2)
Cell Formulas
RangeFormula
B1:B7B1=IFERROR(TRIM(RIGHT(SUBSTITUTE(LEFT(A$1,FIND("#",SUBSTITUTE(A$1&"@","@","#",ROWS(B$1:B1)))-1),"@",REPT(" ",99)),99)),"")
 
Upvote 0
Assume the data is in cell A1. Try this at B1.
=TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",100)),1+100*(ROW($A$1:$A$50)-1),50))
 
Upvote 0
Assume the data is in cell A1. Try this at B1.
=TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",100)),1+100*(ROW($A$1:$A$50)-1),50))
Depending on just what the data can be like, that could easily fail.
Try it with this text in A1

AAAAAAAAAAA, BBBBBBBBBBB, CCCCCCCCCCC,DDDDDDDDDDD,EEEEEEEEEE,FFF,GGG
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,607
Members
449,090
Latest member
vivek chauhan

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