Copy sheets to New Workbook - Excel 2007

H

hgoslin

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
 
H

hgoslin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top