View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default export to csv macro

Try this PM4

Sub ActiveSheet_To_CSV_File()
Dim wb As Workbook
Dim strdate As String
Dim Fname As String
strdate = Format(Date, "mmyyyy")
Fname = ActiveSheet.Name _
& " " & strdate & ".csv"
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs Fname, FileFormat:=xlCSV
.Close False
End With
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"PM4" wrote in message ...

Hi,

I'm looking for a macro in excel that lets me export to csv.
The filename must be the name of the sheet combined with the month and
year on the moment of export (like finance-052006.csv).
Can somebody help me out? I've been searching for a few hours but no
luck so far. I found macro's with static filenames or with a prompt. I
even tried to eddit the macro's but only got some errors.
It looks like i'll be working woth macro's much more the next few
months so i'm going to spend more time understanding it.

Kind regards,
PM.


--
PM4
------------------------------------------------------------------------
PM4's Profile: http://www.excelforum.com/member.php...o&userid=34025
View this thread: http://www.excelforum.com/showthread...hreadid=537853