Macro to save Excel file with date and time in the file name?

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

Guest

Does someone out there have a macro that when executed would save the current
Excel spreadsheet in the form "filename-current date-current time.xls" and
leave the file open for editing? Ideally, I would like to pin the macro to a
button on the user's toolbar. Thank you for you help in advance.
Troy
 
With Activeworkbook
.SaveAs .Filename & "-" & Format(Now,"dd-mmm-yyyy-hh-mm-ss")
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
sonic_d_hog said:
Does someone out there have a macro that when executed would save the
current
Excel spreadsheet in the form "filename-current date-current time.xls" and
leave the file open for editing? Ideally, I would like to pin the macro
to a
button on the user's toolbar. Thank you for you help in advance.
Troy

If you already have a file named Xxxxxx-date-time.xls:

=========================
Public Sub SaveAsDateTime()

With ActiveWorkbook
.SaveAs Left(ActiveWorkbook.FullName, _
InStr(1, ActiveWorkbook.FullName, "-")) _
& Format(Now, "yyyymmdd-hhmmss") & ".xls"
End With

End Sub
=========================

Ciao
Bruno
 

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