Export Excel Worksheets with VBA

Sub ExportSheetsToCSV() Dim xWs As Worksheet Dim xcsvFile As String For Each xWs In Application.ActiveWorkbook.Worksheets If xWs.Name = "INDEX" Or _ xWs.Name = "" Then 'Not extract Worksheets from the list Else xWs.Copy xcsvFile = CurDir & "\" & xWs.Name & ".csv" Application.ActiveWorkbook.SaveAs Filename:=xcsvFile, _ FileFormat:=xlCSV, CreateBackup:=False Application.ActiveWorkbook.Saved = True Application.ActiveWorkbook.Close End If Next End Sub

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.