I have an XLS file containing 512 sheets, I want to have each sheet in separate CSV file, and I'm not going to do this by hand.
Any i开发者_运维知识库dea?
Sub SeparateCSV()
Dim sh As Worksheet
Dim wb As Workbook
For Each sh In ThisWorkbook.Worksheets
sh.Copy
Set wb = ActiveWorkbook
wb.SaveAs sh.Name & ".csv", xlCSV
wb.Close False
Next sh
End Sub
Sub Macro1()
Dim ws As Worksheet
For Each ws In Worksheets
ws.SaveAs Filename:= "C:\" & ws.Name, FileFormat:=xlCSV, CreateBackup:=False
Next ws
End Sub
Save one sheet manually while recording it with the macro recorder, then wrap (and edit) the VBA code in a loop.
精彩评论