VBA Copy Worksheet from workbook to another

ziad alsayed

Well-known Member
Joined
Jul 17, 2010
Messages
665
dear all

i have 2 workbooks, the first is named TopTen1, which i am working in. the second is named TopTen2.

need to open the TopTen2 Workbook from the TopTen1 Workbook and Everytime copy the "Sheet1" To the TopTen1 Workbook and pur at the end and name it TopTen2

how can i write the below Code in a Better Way


Code:
Workbooks.Open Filename:="C:\Users\dv7\Desktop\TopTen2.xlsm"
    Sheets("Sheet1").Select
    Sheets("Sheet1").Copy After:=Workbooks("TopTen1macro.xlsm").Sheets(6)
    Sheets("Sheet1").Select
    Sheets("Sheet1").Name = "Topten2"
    Range("B19").Select


Appreciate any help
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi. Try this

Code:
Workbooks.Open Filename:="C:\Users\dv7\Desktop\TopTen2.xlsm"
Sheets("Sheet1").Copy After:=Workbooks("TopTen1macro.xlsm").Sheets(Sheets.Count)
ActiveSheet.Name = "Topten2"
 
Upvote 0
Try this

Code:
Workbooks.Open Filename:="C:\Users\dv7\Desktop\TopTen2.xlsm"
Sheets("Sheet1").Copy After:=Workbooks("TopTen1macro.xlsm").Sheets(Sheets.Count)
ActiveSheet.Name = "Topten2"
Workbooks("TopTen2.xlsm").Close savechanges:=False
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,845
Members
449,051
Latest member
excelquestion515

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