Recording date/time saved and author name

scotthannaford1973

Board Regular
Joined
Sep 27, 2017
Messages
115
Office Version
  1. 2010
Platform
  1. Windows
Hi

I'd like to be able to create a table that will effectively create an audit log to record when a file is saved - and who saved it - to be added to a named worksheet, with the newest row added to the bottom. I can easily create a one off that does the latest save, but I would like to record all save details :) TIA!

1714643671419.png
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Into ThisWorkbook:

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim xRng As Range
Dim lRow As Integer
With Sheets("log")     'example of sheet name, set as You wish
    lRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    Set xRng = .Range("A3:C" & lRow)
    xRng.Offset(1, 0) = xRng.Value
    .[A2].Value = Format(Now(), "dd-mmm-yy")
    .[B2].Value = Format(Now(), "hh:mm:ss")
    .[C2].Value = Environ("USERNAME")
End With
End Sub
 
Upvote 1
Solution
Into ThisWorkbook:

VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim xRng As Range
Dim lRow As Integer
With Sheets("log")     'example of sheet name, set as You wish
    lRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    Set xRng = .Range("A3:C" & lRow)
    xRng.Offset(1, 0) = xRng.Value
    .[A2].Value = Format(Now(), "dd-mmm-yy")
    .[B2].Value = Format(Now(), "hh:mm:ss")
    .[C2].Value = Environ("USERNAME")
End With
End Sub
works perfectly - many thanks :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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