Save active worksheet to CSV file

  • Thread starter Thread starter Scott
  • Start date Start date
S

Scott

Excuse me, but I am not profficient in Excel macro programming, but
I need some quick help in editing a macro I recorded to save the
active worksheet to a csv file with the sheetname + "_levels". I
have code that works for a specific sheet, but I want a general
macro that will work with the active sheet.

Here is the specific code:

Sub SaveAsBmTopo_LevelsCsv()
'
' SaveAsToBmTopoCsv Macro
' Save Bm_topo sheet to bmtopo_levels.csv

Sheets("bmtopo").Select
ActiveWorkbook.SaveAs Filename:= _
"G:\Standards\levels\bmtopo_levels.csv", FileFormat:=xlCSV
_
, CreateBackup:=False
Workbooks.Open Filename:= _
"G:\Standards\levels\_std_levels.xls"
Workbooks("bmtopo_levels.csv").Close SaveChanges:=False
End Sub

I suspect that I need some sort of variable in place of "bmtopo",
but I can't find any info in the online Help and I don't know the
syntax to add that variable to "_levels".

TIA,
Scott
 
Try

myname = activesheet.name
ActiveWorkbook.SaveAs Filename:= _
"G:\Standards\levels\" & myname & "_levels.csv", FileFormat:=xlCSV

Ole
 
Thanks, I'll try that.

--
Scott

Try

myname = activesheet.name
ActiveWorkbook.SaveAs Filename:= _
"G:\Standards\levels\" & myname & "_levels.csv",
FileFormat:=xlCSV

Ole
 
Back
Top