Skip to content

Instantly share code, notes, and snippets.

@AlexanderMike
Created July 8, 2015 22:19
Show Gist options
  • Select an option

  • Save AlexanderMike/417b2a502109128e670f to your computer and use it in GitHub Desktop.

Select an option

Save AlexanderMike/417b2a502109128e670f to your computer and use it in GitHub Desktop.
'
Public Sub SaveWorksheetsAsCsv()
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
SaveToDirectory = "C:\XXX"
For Each WS In ThisWorkbook.Worksheets
WS.SaveAs SaveToDirectory & WS.Name, xlCSV
Next
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
Application.DisplayAlerts = True
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment