Copy ranges from differant worksheets to active workbook

Pinkster69

New Member
Joined
Jun 19, 2012
Messages
48
Hi Guys,

I know that there have been threads about this but for the life of me I cannot seem to find anything that will help me to copy a range in multiple worksheets in different workbooks and paste them into different worksheets in the active workbook.
I have code that will copy a range in a worksheet and paste it into another worksheet in a different workbook, this all works well but I really need some expertise to help me modify my code as my knowledge is limited.
I have attached a copy of my code for more clarity.

Thanks in advanced guys

Code:
Sub foo()
Dim x As Workbook
Dim y As Workbook


'## Open both workbooks:
Set x = Workbooks.Open("C:\Users\HQ\Downloads\vend-sales-by-hour-42233.csv")    'Workbook where worksheet is to be copied
Set y = Workbooks.Open("C:\Users\HQ\Documents\VBA Code\Forum Questions & Test Code\Test Code\Worksheet Codes\Final Destination.xlsm")   'Workbook where the copied worksheet is to be pasted


'Worksheet Copied from x:
x.Sheets("vend-sales-by-hour-42233").Range("A:Z").Copy


'Paste copied worksheet to y worksheet "Destination"
y.Sheets("First Destination").Range("A:Z").PasteSpecial

ActiveWorkbook.Saved = True
Application.CutCopyMode = False


'Close x & y:
x.Close
y.Close


End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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