macro for displaying last saved workbook

excelNewbie22

Well-known Member
Joined
Aug 4, 2021
Messages
549
Office Version
  1. 365
Platform
  1. Windows
hi,
is there a good macro for displaying (preferable by formula udf) TIME (i.e 18:22:52) AND DATE
for last saved (last closed=saved) workbook?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
found it, although, i need to re-enter the formula everytime to see the change

Code:
Function LastSavedTimeStamp() As Date
  LastSavedTimeStamp = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function


Excel Formula:
=LastSavedTimeStamp()
 
Upvote 0
Here's a macro that might help. Lt me know if it works.

VBA Code:
Sub DisplayLastSavedTime()
    Dim lastSavedTime As String
    
    ' Call the LastSaved UDF to get the last saved date and time
    lastSavedTime = LastSaved()
    
    ' Display the result in a message box
    MsgBox "The workbook was last saved on: " & lastSavedTime, vbInformation, "Last Saved Time"
    
    ' Alternatively, write the result to a specific cell (e.g., Sheet1 cell A1)
    ' ThisWorkbook.Sheets("Sheet1").Range("A1").Value = "Last Saved: " & lastSavedTime
End Sub
 
Upvote 0
Did you include your Function "lastSavedTime" pasted below the macro ? NOTE: you will need to change the name of your Funtcion from LastSavedTimeStamp
to lastSavedTime
 
Upvote 0
like this in screenshot?
if so, still getting an error, attached another pic

btw, why after pasting the picure here and posting it here, it disappearing? unless using the "upload image" button
 

Attachments

  • Untitled.png
    Untitled.png
    42.3 KB · Views: 3
  • Untitled2.png
    Untitled2.png
    5 KB · Views: 2
Upvote 0
Use the following macro. It has been test as working here.

VBA Code:
Option Explicit


Sub DisplayLastSavedTime()
    Dim LastSavedStr As String
    ' Call the LastSaved UDF to get the last saved date and time
    LastSavedStr = GetLastSavedTime()
    
    ' Display the result in a message box
    MsgBox "The workbook was last saved on: " & LastSavedStr, vbInformation, "Last Saved Time"
    
    ' Alternatively, write the result to a specific cell (e.g., Sheet1 cell A1)
    ' ThisWorkbook.Sheets("Sheet1").Range("A1").Value = "Last Saved: " & LastSavedStr
End Sub

Function GetLastSavedTime() As String
    GetLastSavedTime = ActiveWorkbook.BuiltinDocumentProperties("Last Save Time")
End Function
 
Upvote 0
Solution

Forum statistics

Threads
1,225,749
Messages
6,186,802
Members
453,373
Latest member
Ereha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top