albytross
New Member
- Joined
- Sep 22, 2021
- Messages
- 24
- Office Version
- 365
Hi,
I have this code to export all my sheets to CSV.
How can I export all worksheets except for a worksheet named "DONT_EXPORT"?
I have this code to export all my sheets to CSV.
How can I export all worksheets except for a worksheet named "DONT_EXPORT"?
VBA Code:
[QUOTE]
Sub Save_Worksheets_to_CSV()
Dim xWs As Worksheet
Dim xcsvFile As String
Dim Pth As String
Application.ScreenUpdating = False
With Application.FileDialog(4)
.AllowMultiSelect = False
.InitialFileName = "C:\Data\Exports\"
If .Show Then Pth = .SelectedItems(1)
End With
For Each xWs In Application.ActiveWorkbook.Worksheets
xWs.Copy
xcsvFile = Pth & "\" & xWs.Name & ".csv"
Application.ActiveWorkbook.SaveAs fileName:=xcsvFile, _
FileFormat:=xlCSV, CreateBackup:=False
Application.ActiveWorkbook.Saved = True
Application.ActiveWorkbook.Close
Next
End Sub
[/QUOTE]