Copy & Paste sheet to another workbook VBA

Mihael

Board Regular
Joined
Mar 18, 2016
Messages
170
Hi,

I have two open workbooks workbook 1 called (A) en workbook 2 called (B). I need to copy the data from sheet1 workbook (A) and paste it in workbook (B) in sheet called Hexagon. I can't figure this out, can someone help me to figure this out in VBA?
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
If you turn on the Macro Recorder, and record yourself doing this manually, it should give you the VBA code that you need for this.
After you get that, if you need help making it more dynamic, just post the code here along with your needs.
 
Last edited:
Upvote 0
Hi, thats what I did. But I get an error on Sheets("Hexagon").Select

This is the code:

Code:
    Cells.Select
    Selection.Copy
    Workbooks.Open ("J:\Kwaliteit Helmond\Hexagon\Excel Templates\Optiv_\" & Matnr & "_ep.xls")
    Workbooks("10704_EP.xls").Activate
    Sheets("Hexagon").Select
    Cells.Select
    ActiveSheet.Paste

It says "Subscript out of range"
 
Last edited:
Upvote 0
That seems to suggest that there isn't a sheet named "Hexagon" in the file named "10704_EP.xls".
Confirm that the sheet really is there, really is named that, and is not hidden.
 
Upvote 0

Forum statistics

Threads
1,215,564
Messages
6,125,581
Members
449,237
Latest member
Chase S

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