nparsons75
Well-known Member
- Joined
- Sep 23, 2013
- Messages
- 1,256
- Office Version
- 2016
Has anyone ever tried to track changes with VBA. I am currently tring this solution:
The code it states to use is this: I am getting red lines for some reason as in the code, I also get an error when i try it out. Compile Error: Syntax Error:
Hope someone can help I cannot for the life of me get this to work...
HTML:
http://sourcedaddy.com/ms-excel/track-changes-particular-worksheet.html
The code it states to use is this: I am getting red lines for some reason as in the code, I also get an error when i try it out. Compile Error: Syntax Error:
Hope someone can help I cannot for the life of me get this to work...
Code:
Dim vOldVal 'Must be at top of module
Private Sub Worksheet_Change(ByVal Target As Range)
Dim bBold As Boolean
If Target.Cells.Count > 1 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
[COLOR=#ff0000] .Range("A1:E1") = Array("CELL CHANGED",[/COLOR]
[COLOR=#ff0000] "OLD VALUE", _[/COLOR]
[COLOR=#ff0000] "NEW VALUE", "TIME OF CHANGE", "DATE OF[/COLOR]
Change ")"
End If
With .Cells(.Rows.Count, 1).End(xlUp)(2, 1)
.Value = Target.Address
.Offset(0, 1) = vOldVal
With .Offset(0, 2)
If bBold = True Then
.ClearComments
[COLOR=#ff0000] .AddComment.Text Text:= _[/COLOR]
[COLOR=#ff0000] "OzGrid.com:" & Chr(10) & "" &[/COLOR]
Chr (10) & _
"Bold values are the results of"
formulas ""
End If
.Value = Target
.Font.Bold = bBold
End With
.Offset(0, 3) = Time
.Offset(0, 4) = Date
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
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
vOldVal = Target
End Sub
Last edited by a moderator: