Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Copy sheets to New Workbook - Excel 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hgoslin@worldonline.co.za - 30 May 2008 15:13 GMT
Hi
I am trying to copy 3 of the 4 sheets in my Excel Workbook to a new
workbook, save the new work book without the macro and close the
original workbook (containing the source sheets) without saving.  I
keep getting the following error message on the copy sheet code, even
when I record copying the sheets to a new workbook:

Run time error '1004'
Copy method of Sheets class failed

Sub PrepareWB()
Dim Sourcewb As Workbook

   Set Sourcewb = ActiveWorkbook

   Application.ScreenUpdating = False
   MsgBox "A macro to create your workbook is about to run", , "Macro
Running"
   Sourcewb.Sheets(Array("Sale Data 3 Months", _
       "3 Year Bus Plan", "Competitor Analysis")) _
       .Copy
   ActiveWorkbook.SaveAs Filename:= _
       "Chocolates Supreme Dashboard.xlsx", _
       FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

---more code---

   ActiveWorkbook.Save
   Windows("Choclates Supreme.xlsm").Close SaveChanges = False
   Application.ScreenUpdating = True

End Sub
hgoslin@worldonline.co.za - 30 May 2008 15:28 GMT
On May 30, 4:13 pm, hgos...@worldonline.co.za wrote:
> Hi
> I am trying to copy 3 of the 4 sheets in my Excel Workbook to a new
[quoted text clipped - 28 lines]
>
> End Sub

Thanks - I've run it now without errors
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.