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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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??
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top