Can I create a saveas macro that uses a date as the filename

W

wrgpaul

I have created a spreadsheet with a date formula, which will be saved as a
template.
The users of this spreadsheet will be limited as to what they can and can't
enter and the end result needs to be something very simple to use.
I want to add a macro that will allow them to 'saveas' rather than overwrite
an original document. This document will change everyday and will be
identifiable by the date, therefore I'd like the filename to default to
'todays date'.
If this field is contained within the spreadsheet, can this somehow be
specified in the saveas box??
 
D

Dave Peterson

You could add a button from the Forms toolbar to a worksheet and assign it to a
macro that does something like this:

Option Explicit
Sub testme()
Dim myFileName As String

With ActiveWorkbook
myFileName = Left(.FullName, Len(.FullName) - 4) & "_" & _
Format(Date, "yyyymmdd") & ".xls"
.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal
End With
End Sub
 
Top