"Copy method of Sheets class failed" VBA error

mrlex

New Member
Joined
Sep 4, 2013
Messages
10
Hi all, I am trying to create a formula that will copy a worksheet from my activeworkbook to a new document and save.

I have the below code, but when I run it I get an error:

"Copy method of Sheets class failed"

The sheet is not protected (which was my first guess). Any idea how to solve this?

Code:
Sub SampleMacro()
Dim FName As String
Dim Sh As Worksheet


Application.ScreenUpdating = False


FName = "MyBook" & Format(Now(), "dd-mmm-yyyy") 


If Dir("C:\" & FName & ".xlsx") = vbNullString Then
[B][COLOR=#ff0000]    Sheets(Array("Form", "Updates")).Copy [/COLOR][/B]
        For Each Sh In ActiveWorkbook.Worksheets
            With Cells
                .Copy
                .PasteSpecial xlPasteValues
                .PasteSpecial xlPasteColumnWidths
            End With
            Range("A1").Select
        Next Sh
    ActiveWorkbook.SaveAs "C:\" & FName & ".xlsx", xlNormal
End If
     
Application.CutCopyMode = False
Application.ScreenUpdating = False
     
End Sub

 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi mrlex,

Are you trying to copy one worksheet named "Form Updates", or two worksheets named "Form" and "Updates"?

Your description mentions "... copy a worksheet...", but the code is trying to find two worksheets.
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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