ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to name filename with date in macro (https://www.excelbanter.com/excel-programming/401416-how-name-filename-date-macro.html)

Daniel M

how to name filename with date in macro
 
I have a macro that saves off a copy of a file. i would like to put a date
stamp and/or possibly a time stamp on the filename. Is there anyway of doing
this? thanks.

Don Guillett

how to name filename with date in macro
 
From a recent posting of mine.

Goto the small excel icon in the upper left of the screen next to Fileright
clickinsert this.
For today, you will get aaa20071116

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim mydate As String
Application.DisplayAlerts = False
mydate = Format(Date, "yyyymmdd")
SaveAs Filename:="aaa" & mydate & ".xls"
Application.DisplayAlerts = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Daniel M" wrote in message
...
I have a macro that saves off a copy of a file. i would like to put a date
stamp and/or possibly a time stamp on the filename. Is there anyway of
doing
this? thanks.




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

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