ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save active worksheet to CSV file (https://www.excelbanter.com/excel-programming/277894-save-active-worksheet-csv-file.html)

Scott

Save active worksheet to CSV file
 
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

Ole Michelsen

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




Scott

Save active worksheet to CSV file
 
Thanks, I'll try that.

--
Scott

"Ole Michelsen" wrote in
:

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






Scott

Save active worksheet to CSV file
 
Yessiree, that did do it.

Thanks Ole !

--
Scott

"Ole Michelsen" wrote in
:

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






All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com