Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Individual Worksheets in .CSV format

Status
Not open for further replies.

MikeCitizens

Technical User
Aug 13, 2002
37
US
Hello,

We have an excel spreadsheet with several worksheet tabs. I need a macro that we can save individual worksheets to .cvs format

All of my attempts have failed. Im very new at using vb and macros.

This is what I have

Sub SPOT_CSV ()
Windows("AMRATES").Activate
Worksheets ("RATEFEED").Activate
SaveAs Filename:="T:\Spot.CSV", FileFormat:=xlCSV
End Sub


This obviously doesn't work.

Can Anyone help me with this? I would greatly appreciate it.

Mike
 
This bit of code will save all the sheets individually.
It uses the sheet name as part of the filename, so you may want to play about a little:


's will hold a reference to each sheet in turn
Dim s As Variant

For Each s In Workbooks(1).Sheets
'MsgBox s.Name
s.Select ' makes the sheet active, so you can see
'it happening
ActiveWorkbook.SaveAs FileName:= _
"C:\" & s.Name & ".csv", FileFormat:=xlCSV _
, CreateBackup:=False
Next





This version does it without switching the sheets visibly:

Dim s As Variant
For Each s In Workbooks(1).Sheets

s.SaveAs FileName:= _
"C:\" & s.Name & ".csv", FileFormat:=xlCSV _
, CreateBackup:=False
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top