Date and Username log history

ahs004

Board Regular
Joined
Jul 18, 2011
Messages
83
Hi all,

I have a spreadsheet which keeps a log of project status and its used by six project managers.

I have created a tab called Log history.

What i want is to keep a log of computer name and time everytime it is saved.

I have had a go but not there and seek pro help.

I can send the file over if anyone want to have a go but here is the vba
Code:
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
  As Long
  
Function UserName() As String
'   Returns the name of the logged-in user
    Dim Buffer As String * 100
    Dim BuffLen As Long
    BuffLen = 100
    GetUserName Buffer, BuffLen
    UserName = Left(Buffer, BuffLen - 1)
End Function
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Anextrow As Long
Dim Bnextrow As Long
Anextrow = Cells(Rows.Count, "A").End(xlUp).Row + 1
Bnextrow = Cells(Rows.Count, "B").End(xlUp).Row + 1
If Target.Cells.Count > 1 Then Exit Sub
        If Not Intersect(Target, Range("A5:J200")) Is Nothing Then
                With Range("a" & Anextrow).Select
                ActiveCell = Now
                 Range("B" & Bnextrow).Select
                 ActiveCell = UserName
                
                End With
        End If
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,224,800
Messages
6,181,045
Members
453,014
Latest member
Chris258

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