PC Review


Reply
Thread Tools Rate Thread

Copy sheets to New Workbook - Excel 2007

 
 
hgoslin@worldonline.co.za
Guest
Posts: n/a
 
      30th May 2008
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

 
Reply With Quote
 
 
 
 
hgoslin@worldonline.co.za
Guest
Posts: n/a
 
      30th May 2008
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
> 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


Thanks - I've run it now without errors
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you copy saved excel sheets to a new workbook chrisnsmith Microsoft Excel Misc 2 14th Feb 2009 04:21 PM
Copy Two Visible Ranges (From Two Sheets) To A New Workbook (AlsoWith Two Sheets) septhemis@gmail.com Microsoft Excel Programming 3 30th Jan 2009 04:20 PM
Re: Copy Two Visible Ranges (From Two Sheets) To A New Workbook (AlsoWith Two Sheets) septhemis@gmail.com Microsoft Excel Programming 0 29th Jan 2009 01:35 PM
Copy Data from Excel 2007 XLSM workbook to Excel 2003 XLS workbook using ADO Andy Microsoft Excel Programming 2 27th Jul 2007 10:44 PM
why i cant copy sheets in excel workbook =?Utf-8?B?cm9sYW5k?= Microsoft Excel Misc 1 24th Mar 2007 02:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:53 PM.