Copying n times a range of data to each row of data from two adjacent columns

doremi

New Member
Joined
Mar 30, 2022
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone, how I can change this VBA to copy two columns instead of one? Lets say the B column is actually C column and there is one extra column - for the purpose of explanation I will add one more column before A. Now - both columns are with the same number of rows (A and B) instead of the one column which is in the example below. I need to copy both of them. I tried to change the macro but without success so I rather left it as it was. Your help is greatly appreciated.

Sub elgre()
Dim Rng As Range, Cl As Range

Set Rng = Range("B2", Range("B" & Rows.count).End(xlUp))
For Each Cl In Range("A2", Range("A" & Rows.count).End(xlUp))
With Range("H" & Rows.count).End(xlUp).Resize(Rng.count)
Cl.Copy .Offset(1)
.Offset(0, 1).Value = Rng.Value
End With
Next Cl
End Sub
 

Attachments

  • macro change.jpg
    macro change.jpg
    29 KB · Views: 19

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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