scotthannaford1973
Board Regular
- Joined
- Sep 27, 2017
- Messages
- 115
- Office Version
- 2010
- Platform
- Windows
hi
using the code below to record changes to cells in a worksheet called "Master List"; it works almost perfectly except it doesn't put the old cell value into the tracker, but instead "Empty Cell". Most of the changes to be tracked are changing text / numbers to text / numbers but it always shows the old value as "Empty Cell".
TIA!
using the code below to record changes to cells in a worksheet called "Master List"; it works almost perfectly except it doesn't put the old cell value into the tracker, but instead "Empty Cell". Most of the changes to be tracked are changing text / numbers to text / numbers but it always shows the old value as "Empty Cell".
TIA!
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sh.Name = "Master List" Then
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 Sheets("Tracker")
'.Unprotect Password:="Secret"
If .Range("A1") = vbNullString Then
.Range("A1:e1") = Array("Sheet/Cell", "Old Value", "New Value", "Time/Date", "User")
End If
With .Cells(.Rows.Count, 1).End(xlUp)(2, 1)
.Value = ActiveSheet.Name & " : " & Target.Address
.Offset(0, 1) = vOldVal
With .Offset(0, 2)
If bBold = True Then
.ClearComments
End If
.Value = Target
.Font.Bold = bBold
End With
.Offset(0, 3) = Date
.Offset(0, 4) = 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 If
End Sub
Last edited by a moderator: