copy worksheet and paste in another workbook

vijay2482

Board Regular
Joined
Mar 3, 2009
Messages
142
i have 2 workbooks.
i want to copy the 5th worksheet from the 1st workbook and paste it in the 7th sheet of my second workbook.

how to do this?

thanks in advance
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
This works on my Test workbooks:
Code:
Sub copytest()
'Assign Workbook Variables
    VarW1 = Workbooks(2).Name
    VarW2 = Workbooks(3).Name
'Assign WorkSheet Variables
    VarS1 = Workbooks(VarW1).Sheets(5).Name
    VarS2 = Workbooks(VarW2).Sheets(7).Name
'Copy to Destination
    Workbooks(VarW1).Sheets(VarS1).Cells.Copy _
    Workbooks(VarW2).Sheets(VarS2).Range("A1")
End Sub

Note: Workbooks (2) and (3) are my first and second open workbook. I could not use Workbook(1), since that is my Hidden Macro workbook, "Personal.xls". If you do not use a "Personal.xls" workbook, change (2) and (3) to (1) and (2).

Also, Workbooks (2) and (3) are in the order they were opened, adjust as needed.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,254
Members
452,900
Latest member
LisaGo

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