View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ole Michelsen Ole Michelsen is offline
external usenet poster
 
Posts: 6
Default Save active worksheet to CSV file

Try

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

Ole

"Scott" wrote in message
...
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