VBA in Footer to show who updated and when.

RandyD123

Active Member
Joined
Dec 4, 2013
Messages
296
Office Version
  1. 2016
Platform
  1. Windows
I am trying to use some VBA to update my right footer to show who updated the sheet and when. It should read out as "Last Updated By %username% on Dec 07, 2023" This should change ONLY if someone has made a change to the sheet. Simply saving it with no change should not change the stamp in the right footer.

I have 2 tabs (Tab1, Tab2) that need to show when they were updated independent of each other. I am using this code but the time seems to be off a little when I run it and iit doesn't show who updated it.

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim wkSht As Worksheet
    For Each wkSht In ActiveWorkbook.Worksheets
        wkSht.PageSetup.RightFooter = "&8Last Saved : " & _
            Format(ThisWorkbook.BuiltinDocumentProperties("Last Save Time"), _
            "mmm dd yyyy    hh:mm:ss")
    Next wkSht
End Sub

Any help would be most appreciated. Thank you.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Replace your code with this (in the ThisWorkbook module):
VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Sh.PageSetup.RightFooter = "Last updated by " & Environ("USERNAME") & " on " & Format(Now, "Mmm dd, yyyy")
End Sub
 
Upvote 0
Solution
Replace your code with this (in the ThisWorkbook module):
VBA Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Sh.PageSetup.RightFooter = "Last updated by " & Environ("USERNAME") & " on " & Format(Now, "Mmm dd, yyyy")
End Sub
Works perfectly. Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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