Good Morning All,
I am looking to track changes to a specific section of cells, after doing some digging i've found and modified the code below that in general terms works but I am having a couple of problems tha tI can't yet solve.
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal target As Range)
Dim bBold As Boolean
If N = 0 Then Exit Sub
'If target.Cells.Count > 1 Then Exit Sub
If Intersect(target, ActiveSheet.Range("RL32:RR140")) Is Nothing Then Exit Sub
On Error Resume Next
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
If IsEmpty(vOldVal) Then vOldVal = "Empty Cell"
bBold = target.HasFormula
With Sheet2
.Unprotect Password:="Secret"
If .Range("A1") = vbNullString Then
.Range("A1:G1") = Array("SHEET CHANGED", "CELL CHANGED", "OLD VALUE", _
"NEW VALUE", "TIME OF CHANGE", "DATE OF CHANGE", "USERNAME")
End If
With .Cells(.Rows.Count, 1).End(xlUp)(2, 1)
.Value = ActiveSheet.Name
.Offset(0, 1) = target.Address
.Offset(0, 2) = vOldVal
With .Offset(0, 3)
If bBold = True Then
.ClearComments
.AddComment.Text "Logged:" & Chr(10) & "" & Chr(10) & _
"Bold values are the results of formulas"
End If
.Value = target
.Font.Bold = bBold
End With
.Offset(0, 4) = Time
.Offset(0, 5) = Date
.Offset(0, 6) = Application.UserName
End With
.Cells.Columns.AutoFit
.Protect Password:="Secret"
End With
vOldVal = vbNullString
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
On Error GoTo 0
End Sub
1. The range "RL32:RR140" are all the results of a formula and code above will track changes to the cells that drive these results but not the result itself (that lies within the above range) - how can the code be modified to look at the results of the formula?
2. Column RK contains names of agents that I would like to be flagged in the log sheet, I can create the column entry within the log sheet but am at a loss at how I can for example after identifying a change to the formula result in cell RR48, get the value within RJ48.
Any Help will be appreciated, in the meantime i'll be heading back to Google.
Bookmarks