ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Put Date Worksheet last saved in cell (https://www.excelbanter.com/excel-discussion-misc-queries/147411-put-date-worksheet-last-saved-cell.html)

duketter

Put Date Worksheet last saved in cell
 
Excel 2003 - Does anyone know of a function or possible macro that
automatically will put the date the worksheet was last saved in cell A1 of a
spreadsheet. So when the user hits the save button this date gets
automatically updated. If the user just opens the spreadsheet but does not
do anything to it or save it then the date would not change.

A function would be best if possible as then the user doesn't have to accept
running macro's when they first open the spreadsheet. If that isn't possible
then some coding will do.

Thanks!

Ron de Bruin

Put Date Worksheet last saved in cell
 
Hi duketter

You can paste this event in the thisworkbook module

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
'If you save the file the date/time will be placed in cell A1 of Sheet1
Sheets("Sheet1").Range("A1").Value = Format(Now, "yyyy-mmm-dd hh:mm:ss")
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"duketter" wrote in message ...
Excel 2003 - Does anyone know of a function or possible macro that
automatically will put the date the worksheet was last saved in cell A1 of a
spreadsheet. So when the user hits the save button this date gets
automatically updated. If the user just opens the spreadsheet but does not
do anything to it or save it then the date would not change.

A function would be best if possible as then the user doesn't have to accept
running macro's when they first open the spreadsheet. If that isn't possible
then some coding will do.

Thanks!


Mike H

Put Date Worksheet last saved in cell
 
How about:-

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Worksheets("sheet1").Range("A1").Value = Now
End Sub

Mike

"duketter" wrote:

Excel 2003 - Does anyone know of a function or possible macro that
automatically will put the date the worksheet was last saved in cell A1 of a
spreadsheet. So when the user hits the save button this date gets
automatically updated. If the user just opens the spreadsheet but does not
do anything to it or save it then the date would not change.

A function would be best if possible as then the user doesn't have to accept
running macro's when they first open the spreadsheet. If that isn't possible
then some coding will do.

Thanks!



All times are GMT +1. The time now is 11:43 AM.

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