View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default 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.