save excel file into csv format using vba

me_gem69

New Member
Joined
May 23, 2011
Messages
9
Hi i am new to vba
I want to save the excel file in csv format on the web server.
this is a daily process to do.
more over i want to give the filename as the cell value which is a drop-down so as the person select any value in the drop-down & clicks the save button its should save the file on name selected in the drop-down.
plz help.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try this:

Sub Macro2()
ActiveWorkbook.SaveAs Filename:="C:\Documents\" & Range("CELLID") & ".csv" _
, FileFormat:=xlCSV, CreateBackup:=False
End Sub
 
Upvote 0
thanks for you help
here the problem is the cell value is from sheet1 & the data to be store is from sheet 3
 
Upvote 0
A CSV file can only have a single sheet in it so you would need to copy the data from Sheet 3.

Try this


Sub CopyForCSV()
Dim wb As Workbook
Dim ws As Worksheet
Sheets("Sheet3").Activate
Cells.Copy
Workbooks.Add
Cells.PasteSpecial xlPasteAll
Set wb = Workbooks.Open("M:\Access Files\CopySheet.xls")
Sheets("Play").Activate
Range("A2").Copy
ActiveWorkbook.Close
Rows(1).Insert
Range("a1").PasteSpecial xlPasteAll
ActiveWorkbook.SaveAs Filename:="M:\Access Files\" & Range("A1") & ".csv" _
, FileFormat:=xlCSV, CreateBackup:=False
Rows(1).Delete
ActiveWorkbook.Save
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,579
Messages
6,179,656
Members
452,934
Latest member
mm1t1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top