maybe_dbs
02-28-2018, 03:30 AM
Some sample data:
Fruit Type | Price | Weight
Apple | $1 | 0.5
Pear | $2 | 0.3
Apple | $1.2 | 0.4
Banana | $1.1 | 0.2
I need a macro that does this:
Sort the data by Fruit Type (a categorical variable). Then, for all the Apples, copy and paste them somewhere. For all the Bananas, copy and paste them somewhere. For all the Pears, copy and paste them somewhere.
However, the solution needs to fit any Fruit Type (I won't know in advance what my categories are).
How can I solve this? I am open to using VBA. I cannot figure out how to split the data by categories. Is there any function or method that does this?
Fruit Type | Price | Weight
Apple | $1 | 0.5
Pear | $2 | 0.3
Apple | $1.2 | 0.4
Banana | $1.1 | 0.2
I need a macro that does this:
Sort the data by Fruit Type (a categorical variable). Then, for all the Apples, copy and paste them somewhere. For all the Bananas, copy and paste them somewhere. For all the Pears, copy and paste them somewhere.
However, the solution needs to fit any Fruit Type (I won't know in advance what my categories are).
How can I solve this? I am open to using VBA. I cannot figure out how to split the data by categories. Is there any function or method that does this?