ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Today's date as file name .csv in Xl 2007 (https://www.excelbanter.com/excel-programming/433025-todays-date-file-name-csv-xl-2007-a.html)

LuisE

Today's date as file name .csv in Xl 2007
 
What is the code to save a file as a csv which name is today's date? I'm
using Excel 2007.

Thanks in advance

Ron de Bruin

Today's date as file name .csv in Xl 2007
 
Hi LuisE

See
http://www.rondebruin.nl/saveas.htm

Use
FileExtStr = ".csv": FileFormatNum = 6


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"LuisE" wrote in message ...
What is the code to save a file as a csv which name is today's date? I'm
using Excel 2007.

Thanks in advance


Rick Rothstein

Today's date as file name .csv in Xl 2007
 
You didn't say what format you would want the date in (remembering, of
course, that you can't use slashes in a file name) nor whether you were
trying to save a single worksheet or the entire workbook. Assuming you
wanted to only save a single worksheet, you could use this code line to do
what you asked (note that the $ sign on the Date function call is required;
also, change the directory path from my example "d:\temp" to wherever you
actually want to save it at)....

Worksheets("Sheet1").SaveAs "d:\temp\" & Date$ & ".csv", xlCSV

Or you can make your own date format string using the Format function,
something like this...

Worksheets("Sheet1").SaveAs "d:\temp\" & Format(Date, _
"ddmmmyyyy") & ".csv", xlCSV

You may want to look up the SaveAs method in the help files as there are
additional options available.

--
Rick (MVP - Excel)


"LuisE" wrote in message
...
What is the code to save a file as a csv which name is today's date? I'm
using Excel 2007.

Thanks in advance




All times are GMT +1. The time now is 10:44 PM.

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