How do I save each sheet in an Excel workbook to separate CSV
files with a macro?
I have an excel with multiple sheets and I was looking for a macro that will save each sheet to a separate CSV (comma separated file)
. Excel will not allow you to save all sheets to different CSV
files.
If not, you can check the checkbox before Worksheet name to select all sheets; (2) Check the Specify save format option; (3) Click the box below Specify save format option, and select CSV (Macintosh)(*.
You can't have multiple sheets in CSV, because CSV doesn't have sheets.
@AlexDuggleby: you don't need to copy the worksheets, you can save them directly. e.g.:
Public Sub SaveWorksheetsAsCsv() Dim WS As Excel.Worksheet Dim SaveToDirectory As String SaveToDirectory = "C:\" For Each WS In ThisWorkbook.Worksheets WS.SaveAs SaveToDirectory & WS.Name, xlCSV Next End Sub
Only potential problem is that that leaves your workbook saved as the last csv file. If you need to keep the original workbook you will need to SaveAs it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With