Hi,
I'm trying to track changes from the the sheet "Main" and document/track these changes back in sheet "Tracking".
However when I make some changes in sheet main, nothing happens in the sheet tracking. Any idea why?
The code I'm using is the following:
Dim oldAddress As String
Dim oldValue As String
-----------------------------------------------------------------
Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
Dim sh As String
sh.name = "Main"
If WS.name <> Tracking Then
Application.EnableEvents = False
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("A" & Target.Row)
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 1).Value = Range("B" & Target.Row)
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 2).Value = Range("C" & Target.Row)
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 3).Value = Range("D" & Target.Row)
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 4).Value = oldValue
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 5).Value = Target.Value
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 6).Value = Environ("username")
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 7).Value = Now
Sheets("Tracking").Hyperlinks.Add anchor:=Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 8), Address:="", SubAddress:="'" & WS.name & "'!" & oldAddress, TextToDisplay:=oldAddress
End If
Application.EnableEvents = True
End Sub
---------------------------------------------------------
Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal Target As Range)
On Error GoTo Err
oldValue = Target.Value
oldAddress = Target.Address
Err:
End Sub
I'm trying to track changes from the the sheet "Main" and document/track these changes back in sheet "Tracking".
However when I make some changes in sheet main, nothing happens in the sheet tracking. Any idea why?
The code I'm using is the following:
Dim oldAddress As String
Dim oldValue As String
-----------------------------------------------------------------
Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
Dim sh As String
sh.name = "Main"
If WS.name <> Tracking Then
Application.EnableEvents = False
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Range("A" & Target.Row)
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 1).Value = Range("B" & Target.Row)
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 2).Value = Range("C" & Target.Row)
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 3).Value = Range("D" & Target.Row)
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 4).Value = oldValue
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 5).Value = Target.Value
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 6).Value = Environ("username")
Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 7).Value = Now
Sheets("Tracking").Hyperlinks.Add anchor:=Sheets("Tracking").Range("A" & Rows.Count).End(xlUp).Offset(0, 8), Address:="", SubAddress:="'" & WS.name & "'!" & oldAddress, TextToDisplay:=oldAddress
End If
Application.EnableEvents = True
End Sub
---------------------------------------------------------
Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal Target As Range)
On Error GoTo Err
oldValue = Target.Value
oldAddress = Target.Address
Err:
End Sub