VBA in Footer to show who updated and when.

RandyD123

Active Member
Joined
Dec 4, 2013
Messages
289
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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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,215,102
Messages
6,123,099
Members
449,096
Latest member
provoking

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