Loop through ranges to copy from other workbook

markm94

New Member
Joined
Sep 2, 2019
Messages
4
Hi All,

I have a VBA Macro that does the job but I am trying to improve it and I am not able to figure it out, I would really appreciate your help.
To update my ActiveWorkbook I open another Workbook from a hyperlink and need to copy a list of ranges. Currently I am simply repeating the code to Activate one workbook, select the range, copy, activate the ActiveWorkbook and then select the target range and paste. Since I have a lot of ranges I need to copy this is a very tedious job and my Macro is very long. I hope there is a way to just loop through the ranges and perhaps even set value=value instead of copy pasting as this might make it faster?

For example, I need to copy
Sheets("Jan").Range("B4") to the ActiveWorkbook Sheets("Jan").Range("C4"), then
Sheets("Jan").Range("F2:G4") to the ActiveWorkbook Sheets("Jan").Range("G2:H4"), then
I need to copy Sheets("Feb").Range("B4") to the ActiveWorkbook Sheets("Feb").Range("C4"), then
Sheets("Feb").Range("F2:G4") to the ActiveWorkbook Sheets("Feb").Range("G2:H4"), etc

This goes on for all 12 months and some other sheets as well that I need to copy data from. Is there a way I can simply have a list of all the sheets and ranges that need to be copied and where they need to be pasted? And then the Macro loops through those?

Thank you!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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