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
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