Help retrieving text after 2nd, 3rd coma in cell

gdnimrod

New Member
Joined
Jul 11, 2011
Messages
2
Hello,

I have a bunch of cells in this format

NYC,TARGET,LUX
TARGET
NYC,TARGET,FRA,DUB

i.e some with a single item, some with 4 as in the last case. I need to seperate them into different columns.

I used this code for seperating them with an instance of a single item

Code:
IFERROR(LEFT(Q12,FIND(",",Q12)-1),Q12)
and this to get in between the first and 2nd comas:
Code:
=IFERROR(IFERROR(LEFT((MID(Q13,FIND(",",Q13)+1,LEN(Q13)-LEN(U13)-1)),FIND(",",MID(Q13,FIND(",",Q13)+1,LEN(Q13)-LEN(U13)-1))-1),MID(Q13,FIND(",",Q13)+1,LEN(Q13)-LEN(U13)-1)),"")

To get the item after the 3rd coma, i used this
Code:
=IFERROR(RIGHT(Q12,LEN(Q12)-FIND(",",Q12,FIND(",",Q12,1)+1)-FIND(",",Q12,FIND(",",Q12,1)+1)+1),"")

My real issue is i cant seem to get the code right to parse the text between the 2nd and 3rd comas.

Thank you in advance:)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Welcome to the board..

Try
Data - Text To Columns
Deliminated - Next
Comma - Finish


Hope that helps.
 
Upvote 0
Thanks a lot, and thank you for that.
Indeed i did it that way at first, but i was told i require to have it written in code.
 
Upvote 0
Try this for the first one, in say B1

=LEFT(A1,FIND(",",A1&",")-1)

Then in C1 and filled right as far as needed

=TRIM(LEFT(MID(SUBSTITUTE($A1&",",",",REPT(" ",LEN($A1)+1)),(LEN($A1)+1)*(COLUMNS($A1:A1)),(LEN($A1)+1)*(COLUMNS($A1:A1))),LEN($A1)+1))
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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