Audit trail of changees in values in specific columns

Spoursy

New Member
Joined
Dec 4, 2019
Messages
32
Office Version
  1. 365
Platform
  1. Windows
Ive watched the following video to create an audit trail


The code Im using is
Option Explicit
Dim wsLOE As Worksheet, wsTrail As Worksheet
Dim PreviousValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
Set wsTrail = ThisWorkbook.Worksheets("Trail")
If Target.Column = 3 Or Target.Column = 4 Then
If Target.Value <> PreviousValue Then
Call Log_Change(Target)
End If
End If
End Sub
Private Sub Log_Change(ByVal Cell_Target As Range)
Dim RowInsertion As Long
RowInsertion = wsTrail.Cells(Rows.Count, "A").End(xlUp).Row + 1
wsTrail.Cells(RowInsertion, "A").Value = _
Application.UserName & " changed cell " & Cell_Target.Address _
& " from " & PreviousValue & " to " & Cell_Target.Value _
& " on LOE worksheet"
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
PreviousValue = Target.Value
End Sub
Private Sub Worksheet_Deactivate()
Set wsLOE = Nothing
Set wsTrail = Nothing
End Sub

but I am getting a yellow hightlight at
RowInsertion = wsTrail.Cells(Rows.Count, "A").End(xlUp).Row + 1

any ideas on a fix to this?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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