VBA - Last saved user

Rehmatm

New Member
Joined
Mar 17, 2014
Messages
6
Hi, Hope someone can help me.. I have a shared document which is being used by multiple people. I want to be able to capture who and when someone saves changes. This is the code I have at the moment.

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Worksheets("UserLog").Activate
Range("A1") = "This file last saved ""By"" who ""On"", list!"
Range("A65536").End(xlUp).Offset(1, 0) = _
"By: " & Application.UserName & ", On: " & Now & " "
End Sub

What I want the code to do is, save the last users information in the 'UserLog' sheet and return the user back to the sheet they were working on (they do not need to see the UserLog sheet)

Can someone help. All help is appreciated.

Many Thanks

R
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
With Worksheets("UserLog")
    .Range("A1") = "This file last saved ""By"" who ""On"", list!"
    .Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = _
    "By: " & Application.UserName & ", On: " & Now & " "
End With
End Sub
 
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,163,982
Messages
5,834,704
Members
430,310
Latest member
Excelorate3305

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