ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Enter current date automatically in filename (https://www.excelbanter.com/excel-worksheet-functions/127710-enter-current-date-automatically-filename.html)

Megadrone

Enter current date automatically in filename
 
Excel 2000
When saving a file in a Macro, I want to automatically insert the current
date in the file name.

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\John\My Documents\Books(DATE HERE).xls",
FileFormat:=xlNormal _
, CreateBackup:=False

Result: Books01/25/07.xls

CoRrRan

Enter current date automatically in filename
 
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\John\My Documents\Books" & Format
(Date,"yymmdd") & ".xls", FileFormat:=xlNormal

HTH, CoRrRan

?B?TWVnYWRyb25l?= wrote in
:

Excel 2000
When saving a file in a Macro, I want to automatically insert the
current date in the file name.

ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\John\My Documents\Books(DATE
HERE).xls",
FileFormat:=xlNormal _
, CreateBackup:=False

Result: Books01/25/07.xls




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

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