Help with macro for copying sheet to existing workbook

patrick200

New Member
Joined
Jan 14, 2013
Messages
21
Hi all
I'm trying to copy one sheet and insert it to another existing workbook (storing it for future reference)..... It will copy the sheet but it also copies over the other sheets already in the workbook..........I have no idea what I've done wrong

I'm using Excel 2010 on Windows7

here's the code I have so far

Sub Sample()
Workbooks.Open Filename:=("C:\Users\laptop\Desktop\SAVEDSCHEDULE.xlsx")
Windows("Test Schedule - Copy.xlsm").Activate
Sheets("Sheet3").Select
Sheets("Sheet3").Copy Before:=Workbooks("SAVEDSCHEDULE.xlsx").Sheets(1)
Application.DisplayAlerts = False
Workbooks("SAVEDSCHEDULE.xlsx").SaveAs "C:\Users\laptop\Desktop\SAVEDSCHEDULE.xlsx"
Application.DisplayAlerts = True
Workbooks("SAVEDSCHEDULE.xlsx").Close
End Sub


Thanks.......Pat
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,461
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
There's nothing in the code that would copy more than Sheet3 that I can see. Have you tried stepping through the code (press F8 key repeatedly) to see what's happening? Have you checked to see that you have not grouped all the sheets when the code is run?
 

patrick200

New Member
Joined
Jan 14, 2013
Messages
21
There's nothing in the code that would copy more than Sheet3 that I can see. Have you tried stepping through the code (press F8 key repeatedly) to see what's happening? Have you checked to see that you have not grouped all the sheets when the code is run?

Hi there.....Thanks for the reply
Thats actually what I want to do......Copy sheet3 and save it in another workbook...then, as "data" is changed in the original sheet3....I want to save a new copy of sheet3 in front of the old in the other workbook.......I hope this makes sense.......but as I save a new sheet3 to the other workbook the sheet3 that was previously saved changes to the new sheet3.........It's actally very odd.....I have no idea how to correct it.


Thanks...Pat
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,461
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hi there.....Thanks for the reply
Thats actually what I want to do......Copy sheet3 and save it in another workbook...then, as "data" is changed in the original sheet3....I want to save a new copy of sheet3 in front of the old in the other workbook.......I hope this makes sense.......but as I save a new sheet3 to the other workbook the sheet3 that was previously saved changes to the new sheet3.........It's actally very odd.....I have no idea how to correct it.


Thanks...Pat
You can't copy a sheet to a workbook that has the same name as an existing sheet in that workbook.
 

patrick200

New Member
Joined
Jan 14, 2013
Messages
21
AH HA....... Thanks.....I'll rename the sheet before I paste it

Thanks for the info.......Pat
 

Forum statistics

Threads
1,136,636
Messages
5,676,909
Members
419,658
Latest member
jahbro

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
Top