Macro?: Copy & Paste from Two Lists

okie_ryan

New Member
Joined
Jun 30, 2016
Messages
2
Greetings. I have two sets of data in the Sample below. I am looking for a way to automatically create the Outcome: each value in Column A paired with each value in Column B - creating two new datasets in Columns C and D.

The solution must work for much larger datasets. THANK YOU!!

Sample
[TABLE="class: grid, width: 100"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Up[/TD]
[TD]Red[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Down[/TD]
[TD]Yellow[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]Red[/TD]
[/TR]
</tbody>[/TABLE]

Outcome
[TABLE="class: grid, width: 100"]
<tbody>[TR]
[TD][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Up[/TD]
[TD]Red[/TD]
[TD]Up[/TD]
[TD]Red[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Down[/TD]
[TD]Yellow[/TD]
[TD]Up[/TD]
[TD]Yellow[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]Blue[/TD]
[TD]Up[/TD]
[TD]Blue[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD][/TD]
[TD][/TD]
[TD]Down[/TD]
[TD]Red[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD]Down[/TD]
[TD]Yellow[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[TD]Down[/TD]
[TD]Blue[/TD]
[/TR]
</tbody>[/TABLE]
 

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.
Perhaps :-

Code:
Dim rngA As Range, rngB As Range, r#
Set rngA = Range([A1], Cells(Rows.Count, 1).End(xlUp))
Set rngB = Range([B1], Cells(Rows.Count, 2).End(xlUp))
r = rngA.Rows.Count * rngB.Rows.Count
rngA.Copy [C1].Resize(r)
Range([C1], Cells(r, 3)).Sort Key1:=[C1], _
  Order1:=xlDescending, Header:=xlNo
rngB.Copy [D1].Resize(r)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,226,735
Messages
6,192,733
Members
453,752
Latest member
Austin2222

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