Macro to see who has accessed my spreadsheet and when

DPChristman

Board Regular
Joined
Sep 4, 2012
Messages
178
Office Version
  1. 365
Platform
  1. Windows
I know I have asked this before, but I can't find it.

I have a spreadsheet that I have about 7 people regularly accessing.

As is always the case, somebody messes the file up, or leaves it open, so others can't update.

What i am looking for is a macro that will recorded every time a user accesses the file, when, and preferably for how long.

The spreadsheet is already kind of big, pulling data from multiple sources, so I don't want to add more bulk to the size.

If possible, it would be nice to have this macro save historical records, and maybe in another file.

I am currently using Excel 2010. I know some options won't work in 2010
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Thanks, but really not what I am looking for.
The example in the thread you referenced is talking about capturing changes to sell contents.
I am just looking for who went in, and when.
 
Upvote 0
Ok, maybe this then, placed in the ThisWorkbook module

Code:
Private Sub Workbook_Open()
Dim LR As Long
    With Sheets("Sheet2")
        LR = .Range("A" & Rows.Count).End(xlUp).Row
        .Range("A" & LR + 1).Value = Time
        .Range("B" & LR + 1).Value = Environ("UserName")
    End With
End Sub
 
Upvote 0
Thanks. I will give that a shot, and let you know.

Where does the info go? Does it create another tab?




Ok, maybe this then, placed in the ThisWorkbook module

Code:
Private Sub Workbook_Open()
Dim LR As Long
    With Sheets("Sheet2")
        LR = .Range("A" & Rows.Count).End(xlUp).Row
        .Range("A" & LR + 1).Value = Time
        .Range("B" & LR + 1).Value = Environ("UserName")
    End With
End Sub
 
Upvote 0
The info would go on Sheet2, but you can put it anywhere you like by changing the sheet reference in the code here...

Code:
With Sheets("Sheet2")
 
Upvote 0
Also made the sheet hidden
AND the workbook will save as well

Code:
Private Sub Workbook_Open()
Dim LR As Long
    With Sheets("Sheet1")
        LR = .Range("A" & Rows.Count).End(xlUp).Row
        .Visible = False
        .Range("A" & LR + 1).Value = Time
        .Range("B" & LR + 1).Value = Environ("UserName")
    End With
ActiveWorkbook.Save
End Sub
 
Upvote 0
Oops, sorry...it should have been Sheet2 NOT sheet1

Code:
Private Sub Workbook_Open()
Dim LR As Long
    With Sheets("Sheet2")
        LR = .Range("A" & Rows.Count).End(xlUp).Row
        .Visible = False
        .Range("A" & LR + 1).Value = Time
        .Range("B" & LR + 1).Value = Environ("UserName")
    End With
ActiveWorkbook.Save
End Sub
 
Upvote 0
Instead of:
.Range("B" & LR + 1).Value = Environ("UserName")
I prefer:
.Range("B" & LR + 1).Value = Application.UserName
 
Upvote 0
Of course, nothing will be captured if the user:
• closes the workbook without saving;
• deletes the record; or
• disables macros when opening the workbook.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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