• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Save Sheets in Separate File Debug Error

Hi All,

I am using below macro from several days to save each sheet as seprate workbook. Today i have received debug error, not know what is the reason, code is below while error screen shot is also attached:

Sub Splitbook()
'Updateby20140612
Dim xPath As String
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In ThisWorkbook.Sheets
xWs.Copy
Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xlsx"
Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Please help me.
 

Attachments

  • Capture.JPG
    Capture.JPG
    31.9 KB · Views: 6
Hi Shakeel,

I tried with same code from my end and i didn't received any error. If possible could you send me the error message what you are receiving.

Regards
Abdul Matheen
 
Part of your code is missing. You have used xWs but not defined it. You need the following code in your macro

Code:
Dim xWs As Worksheet
 
Back
Top