Logging user access to Spreadsheets

DPChristman

Board Regular
Joined
Sep 4, 2012
Messages
171
Office Version
  1. 365
Platform
  1. Windows
I have seen different versions of this question and suggestions going back a number of years, but nothing recent.

I have a spreadsheet (report log) that is used by everyone in my department.

The problem occurs when one user tries to access the spreadsheet, only to get the message that the spreadsheet is opened by 'another user'.

This is particularly problematic at the beginning of a new fiscal year, because the users are constantly updating the spreadsheet with new reports.

I would like to maintain an automatic user log to keep track of who was in last.

This would make it easier to drop a direct (let me know when you are done) email to that person.

Is there a way to do this?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If the software is installed per user rather than corporate, it tends to say whos in the file
 
Upvote 0
i would create a log sheet

and in this workbook module

Code:
Private Sub Workbook_Open()


Dim name As String
name = Application.UserName
  
   Dim LastRow As Long, ws As Worksheet

    Set ws = Sheets("Log")

    LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1 'Finds the last blank row

    ws.Range("A" & LastRow).Value = name
    ws.Range("B" & LastRow).Value = Now
    

   
   

End Sub


this will put user name in column A and date and time in column B of a sheet called log (sheet name can be anything you like just change code)

edit one line not needed
 
Last edited:
Upvote 0
the code has to go in Thisworkbook

then file saved as xlsm macro enabled then on opening the workbook it should add entry to bottom of sheet called "Log"

sheet has to already be there
 
Upvote 0
Thanks, I actually just figured out the Thisworkbook part.

It is working now.

Is there a way to keep the log updated if the last user did not save before they exited?

Often the problem is that the last person to open the file, left it opened and did not save anything.
 
Upvote 0
just add one line

Code:
Private Sub Workbook_Open()

Dim name As String
name = Application.UserName
Dim LastRow As Long, ws As Worksheet

    Set ws = Sheets("Log")

    LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row + 1 'Finds the last blank row

    ws.Range("A" & LastRow).Value = name
    ws.Range("B" & LastRow).Value = Now

[COLOR=#ff0000]ActiveWorkbook.Save[/COLOR]

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,457
Members
449,083
Latest member
Ava19

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