Comma Seperated Values to Dataset

L

Legacy 143009

Guest
Hi,

I have comma separated values like below:
country1, code1, code2;
country2, code3, code4, code5;
.
.

What would be the best practice to convert to this:
Column A ColumnB
country1 code1
country1 code2
country2 code3
country2 code4
country2 code5
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
How about

VBA Code:
Sub jec()
 Dim ar, sq, sp, j As Long, jj As Long, x As Long
 ar = Range("A1", Range("A" & Rows.Count).End(xlUp))
 ReDim sq(1, 0)
 
 For j = 1 To UBound(ar)
   sp = Split(ar(j, 1), ", ")
   For jj = 1 To UBound(sp)
     ReDim Preserve sq(1, x)
     sq(0, x) = sp(0)
     sq(1, x) = sp(jj)
     x = x + 1
   Next
 Next
 
 Range("A1").Resize(x, 2) = Application.Transpose(sq)
End Sub
 
Upvote 0
Solution
Ok. I'll try tomorrow. I think VBA will be the best solution. I could write one but I was very busy with another code today. My eyes are leaking. Thanks for your time and effort!
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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