Creating a User Log

gruhnelliot

New Member
Joined
Jun 4, 2013
Messages
14
I have a VBA in this workbook (pictured below) that generates a user log each time a user logs in. Column A displays the username. Column B displays the date and time. I would like for column C to show which worksheet they accessed. Is this possible?

I attached the VBA underneath the photo.

1581554561296.png

Dim wksuserlog As Worksheet
Dim lngnextrow As Long


On Error Resume Next
Set wksuserlog = ThisWorkbook.Worksheets("User Log")

On Error GoTo ExitProc
If wksuserlog Is Nothing Then
Set wksuserlog = ThisWorkbook.Worksheets.Add
wksuserlog.Name = "User Log"
wksuserlog.Range("a1:b1").Value = Array("Username", "Date_time")
End If

With wksuserlog
lngnextrow = .cells(.Rows.Count, "a").End(xlUp).Row + 1
.cells(lngnextrow, "a").Value = Environ("Username")
.cells(lngnextrow, "b").Value = Now()
.Columns("a:b").AutoFit
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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