I have a workbook that has 14 worksheets. I'm looking for some code that will split these worksheets out into individual workbooks while retaining formatting.
I did find some code that does essentially what I am looking for:
Unfortunately I also need to tell it to ignore 4 of the worksheets and only break 10 of them out into workbooks.
I tried including the following If statement to no avail:
Any help would be appreciated.
I did find some code that does essentially what I am looking for:
Code:
Sub Splitbook()
'Updateby20140612
Dim xPath As String
xPath = "C:\Users\user\Desktop\Test"
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
I tried including the following If statement to no avail:
Code:
For Each xWs In ThisWorkbook.Sheets
If xWs.Value <> "foo" Then
xWs.Copy
Any help would be appreciated.