Insert "last saved" date into footer

lafontainek

New Member
Joined
Mar 15, 2011
Messages
6
Hello all
all i can find is the =NOW() option, but I can't use NOW, i need date of last save.
i need the footer to read "Dave Evans Last Saved 3/8/2011" and the date to change each time it's saved.
Please and thank you!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Hi. Try this in the ThisWorkbook module

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("Sheet1").PageSetup.LeftFooter = Environ("username") & " Last saved " & Format(Now, "mmmm dd yyyy at h:mm:ss AM/PM")
End Sub
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Hopefully :)

Press ALT + F11 to open the Visual Basic Editor.

In the Project window (normally top left) double click ThisWorkbook.

Copy the code and paste it into the white space on the right.

Press ALT + Q to close the code window.

Check the result by saving the workbook then printing Sheet1.
 

lafontainek

New Member
Joined
Mar 15, 2011
Messages
6

ADVERTISEMENT

when i try to save:
Runtime error '9'
Subscript out of range.

i click debug and it highlights this line in yellow:
Sheets("Sheet1").PageSetup.LeftFooter = Environ("username") & " Last saved " & Format(Now, "mmmm dd yyyy at h:mm:ss AM/PM")

?
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Change Sheet1 to the name of the sheet

Sheets("Sheet1").PageSetup.LeftFooter = Environ("username") & " Last saved " & Format(Now, "mmmm dd yyyy at h:mm:ss AM/PM")
 

lafontainek

New Member
Joined
Mar 15, 2011
Messages
6

ADVERTISEMENT

OK that works! But the name isnt listed.
I tried replacing "username" with Dave Evans but it doesnt appear.
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
If you are using Windows then that should insert the Windows logon name.

Alternatives:

Sheets("Sheet1").PageSetup.LeftFooter = Application.UserName & " Last saved " & Format(Now, "mmmm dd yyyy at h:mm:ss AM/PM")

Sheets("Sheet1").PageSetup.LeftFooter = "Dave Evans" & " Last saved " & Format(Now, "mmmm dd yyyy at h:mm:ss AM/PM")
 

lafontainek

New Member
Joined
Mar 15, 2011
Messages
6
Hmm... i must be doing something wrong, it's not appearing.
I went into print preview and did custom footer just to add his name, but i notice the date and time arent changing each time i save it... it still reads 11:27am even though i've saved it since then, even with a new document name.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,026
Messages
5,835,024
Members
430,332
Latest member
Charly_Moon

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
Top