VBA macro to save each sheet in a workbook to seperate CSV files

Excel VBA macro to save each sheet in a workbook to seperate CSV files.The macro creates seperate CSV file (with sheet name) for each sheet of workbook.

Note: Before you run the below macro, change “C:\test\” in 12th line to your folder path where you want to save the created CSV files for each worksheet.

VBA macro

  1. Sub saveSheetsSeperateCSV()
    Dim sheetsCount
    sheetsCount = 1
    Dim activeSheetName
    Do
    If ActiveSheet.Index = Worksheets.Count Then
        Worksheets(1).Select
    Else
        ActiveSheet.Next.Select
        End If
    activeSheetName = ActiveSheet.Name
    ActiveWorkbook.SaveAs Filename:="C:\test\" & activeSheetName & ".csv", _
    FileFormat:=xlCSV, CreateBackup:=False
    sheetsCount = sheetsCount + 1
    Loop Until sheetsCount > Worksheets.Count
    End Sub

About the Author

SRINI S

A passionate blogger. Love to share solutions and best practices on wordpress hosting, issues and fixes, excel VBA macros and other apps