[code lang=’vb’]Option Explicit
Sub mysaver()
Dim counter As Integer
counter = 1
‘ counter is for the number of sheets in the workbook
Do While counter <= Worksheets.Count
' Worksheets.Count represents the total number of sheets in the workbook
On Error GoTo ErrorHandler
' go to the nominated sheet
Worksheets(counter).Activate
' and save it. Simple...
ActiveSheet.SaveAs FileName:=ActiveSheet.Name, FileFormat:=xlCSV
counter = counter + 1
Loop
MsgBox "All Sheets Saved.", , "Success"
Exit Sub
ErrorHandler:
MsgBox "Error during save - Caution!", vbCritical, "Save Errors"
Exit Sub
End Sub[/code]
- Pada fail excel tekan Alt dan F11 serentak
- Pilih Insert -> Module
- Pindah kod diatas
- Tekan Alt dan Q untuk kembali ke fail excel
- Tekan Alt dan F8 dan klik Run
Sumber: http://www.accountingweb.co.uk/anyanswers/macro-exporting-50-worksheets-csv-one-pass