VBA to separate data in column using comma deliminator then put into new column

TK2019

New Member
Joined
Sep 23, 2019
Messages
2
I some data in lets say column D that has information such as:


Product 1, Product 2, Product 3
Product 4
Product 2, Product 4
Product 7
etc.

What i want to do is use a vba to turn this into one column somewhere else say sheet 2 column A

so: the data would look like
Product 1
Product 2
Product 3
Product 4
Product 2
Product 4
Product 7
etc


if a cell has multiple products, they have comma delimiters otherwise it's just the product by itself.

Can anyone help?
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Assuming your final list will have less than 65,500+ product names, here is a macro that you can use...
Code:
Sub ExpandCommaDelimitedData()
  Dim Arr As Variant
  Arr = Split(Join(Application.Transpose(Range("D1", Cells(Rows.Count, "D").End(xlUp))), ", "), ", ")
  Sheets("Sheet2").Range("A1").Resize(UBound(Arr) + 1) = Application.Transpose(Arr)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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