I've tried to look up how to do this, but with my Macro I keep getting errors and just can't figure it out...
The Macro is designed to automatically save each sheet as it's CSV file. I have a couple sheets at the beginning that I want it to skip. How do I make the Macro automatically skip specific sheets but process everything else? The names and quantity of the sheets that I DO want it to process are not consistent, but the ones I do want to skip remain the same...
The Macro is designed to automatically save each sheet as it's CSV file. I have a couple sheets at the beginning that I want it to skip. How do I make the Macro automatically skip specific sheets but process everything else? The names and quantity of the sheets that I DO want it to process are not consistent, but the ones I do want to skip remain the same...
Code:
Sub SplitWorkbook()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim xWs As Worksheet
Dim xWb As Workbook
Dim FolderName As String
Application.ScreenUpdating = False
Set xWb = Application.ThisWorkbook
DateString = Format(Now, "yyyy-mm-dd hh-mm-ss")
FolderName = xWb.Path & "" & "NA Test Cases " & DateString
MkDir FolderName
For Each xWs In xWb.Worksheets
xWs.Copy
If Val(Application.Version) < 12 Then
FileExtStr = ".csv": FileFormatNum = 6
Else
Select Case xWb.FileFormat
Case 51:
FileExtStr = ".csv": FileFormatNum = 6
Case 52:
If Application.ActiveWorkbook.HasVBProject Then
FileExtStr = ".csv": FileFormatNum = 6
Else
FileExtStr = ".csv": FileFormatNum = 6
End If
Case 56:
FileExtStr = ".csv": FileFormatNum = 6
Case Else:
FileExtStr = ".csv": FileFormatNum = 6
End Select
End If
xFile = FolderName & "" & Application.ActiveWorkbook.Sheets(1).Name & FileExtStr
Application.ActiveWorkbook.SaveAs xFile, FileFormat:=FileFormatNum
Application.ActiveWorkbook.Close False
Next
MsgBox "You can find the files in " & FolderName
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: