I currently have this data in a sheet
Col A Col B
1 angry birds, gaming
2 nirvana,rock,band
What I want to do is split the comma separated entries in the second column and insert in new rows like below:
Col A Col B
1 angry birds
1 gaming
2 nirvana
2 rock
2 band
I am sure this can be done with VBA but couldn’t figure it out myself.
You are better off using variant arrays rather than cell loops – they are much quicker code wise once the data sets are meaningful. Even thoug the code is longer 🙂
This sample below dumps to column C and D so that you can see the orginal data.
Change
[c1].Resize(lngCnt, 2).Value2 = Application.Transpose(Y)to[a1].Resize(lngCnt, 2).Value2 = Application.Transpose(Y)to dump over your original data[Updated with regexp to remove any blanks after
,ie “, band” becomes “band”]