Export each sheets as a CSV files

P

PolarBear

Hi,

I would like to save all the sheets in a workbook to MS-DOS CSV files.
It would be nice if I could export only the selected sheets but that not
really required.

Is there a free addin that will allow me to do that or maybe a macro?

Thanks
 
D

Dave Peterson

You could group the worksheets you want (click on the first worksheet tab and
ctrl-click on subsequent).

Then run a macro like:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim newWks As Worksheet

For Each wks In ActiveWindow.SelectedSheets
wks.Copy 'to a new workbook
Set newWks = ActiveSheet
With newWks
Application.DisplayAlerts = False
.Parent.SaveAs Filename:="C:\TEMP\" & .Name, _
FileFormat:=xlCSV
Application.DisplayAlerts = True
.Parent.Close savechanges:=False
End With
Next wks

End Sub

This saves into a folder named C:\temp (that has to exist) and uses the
worksheet name as the file name. It also overwrites any existing file (if one
exists).

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Top