ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically saving an Excel spreadsheet with today's date in the filename (https://www.excelbanter.com/excel-programming/296666-automatically-saving-excel-spreadsheet-todays-date-filename.html)

Ian M

Automatically saving an Excel spreadsheet with today's date in the filename
 
Firstly, thank you CHRIS for solving my problem relating to disabling
macros - I tried to reply to you but my password is not recognised.

I now wish to save a file with today's date automatically in the
filename, for example:

"Accounts figures 28 April 2004.xls"

Can the date be inserted automatically?

Any ideas?

Thank you.

Kind regards,

Ian M

Chris

Automatically saving an Excel spreadsheet with today's date in the filename
 
Put this code in your Workbook BeforeClose Event found in ThisWorkbook of your project windo

Private Sub Workbook_BeforeClose(Cancel As Boolean
If InStr(ActiveWorkbook.Name, CStr(Format(Now, "dd mmmm yyyy"))) = 0 The
ActiveWorkbook.SaveAs Filename:=
"Accounts figures" & " " & CStr(Format(Now, "dd mmmm yyyy")
End I
End Su

----- Ian M wrote: ----

Firstly, thank you CHRIS for solving my problem relating to disablin
macros - I tried to reply to you but my password is not recognised

I now wish to save a file with today's date automatically in th
filename, for example

"Accounts figures 28 April 2004.xls

Can the date be inserted automatically

Any ideas

Thank you

Kind regards

Ian


Ian M[_2_]

Automatically saving an Excel spreadsheet with today's date in the filename
 
Chris

This works perfectly as well.

Thanks again!

Ian M



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 12:14 PM.

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