Help please.
I found this code and have adjusted slightly to fit my needs.
My spreadsheet is called "Additional Charges" and I want to record any user that makes a change anywhere on the active row.
Code is :
'Set the user who modified the record
Dim ThisRow As Long ' make sure to declare all the variables and appropiate types
ThisRow = Target.Row
'protect Header row from any changes
If (ThisRow = 1) Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "Header Row is Protected."
Exit Sub
End If
If Target.Column >= 1 And Target.Column <= 30 Then
MsgBox Target.Column
Dim sOld As String, sNew As String
sNew = Target.Value 'capture new value
With Application
.EnableEvents = False
.Undo
End With
sOld = Target.Value 'capture old value
MsgBox sOld & "Old"
Target.Value = sNew 'reset new value
MsgBox sNew & "New"
If sOld <> sNew Then
Range("E" & ThisRow).Value = Environ("username")
End If
Application.EnableEvents = True
End If
For some reason the code is only recognising column 1 (and recording if column 1 changes) but does not seem to recognise any other column.
I am probably missing something obvious but Any help much appreciated. Thanks
I found this code and have adjusted slightly to fit my needs.
My spreadsheet is called "Additional Charges" and I want to record any user that makes a change anywhere on the active row.
Code is :
'Set the user who modified the record
Dim ThisRow As Long ' make sure to declare all the variables and appropiate types
ThisRow = Target.Row
'protect Header row from any changes
If (ThisRow = 1) Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
MsgBox "Header Row is Protected."
Exit Sub
End If
If Target.Column >= 1 And Target.Column <= 30 Then
MsgBox Target.Column
Dim sOld As String, sNew As String
sNew = Target.Value 'capture new value
With Application
.EnableEvents = False
.Undo
End With
sOld = Target.Value 'capture old value
MsgBox sOld & "Old"
Target.Value = sNew 'reset new value
MsgBox sNew & "New"
If sOld <> sNew Then
Range("E" & ThisRow).Value = Environ("username")
End If
Application.EnableEvents = True
End If
For some reason the code is only recognising column 1 (and recording if column 1 changes) but does not seem to recognise any other column.
I am probably missing something obvious but Any help much appreciated. Thanks