Hi
I am new to VBA and learning through trial and error. I am hoping there is an easy fix to this solution.
I want to split my Excel tabs into their documents without having to move/copy them. Assuming this is an easy task, I have looked at solutions to this and used code that is already online. However when I run the code I get an error and unable to work out why.
The code i am using is:
Sub SplitEachWorksheet()
Dim FPath As String
FPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Sheets
ws.Copy
Application.ActiveWorkbook.SaveAs Filename:=FPath & "\" & ws.Name & ".xlsx"
Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
The error happens at ws.Copy
Can you guys please help and point me in the right direction. What am I doing wrong?
Much appreciated!!!
Sammy
I am new to VBA and learning through trial and error. I am hoping there is an easy fix to this solution.
I want to split my Excel tabs into their documents without having to move/copy them. Assuming this is an easy task, I have looked at solutions to this and used code that is already online. However when I run the code I get an error and unable to work out why.
The code i am using is:
Sub SplitEachWorksheet()
Dim FPath As String
FPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Sheets
ws.Copy
Application.ActiveWorkbook.SaveAs Filename:=FPath & "\" & ws.Name & ".xlsx"
Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
The error happens at ws.Copy
Can you guys please help and point me in the right direction. What am I doing wrong?
Much appreciated!!!
Sammy