JackDanIce
Well-known Member
- Joined
- Feb 3, 2010
- Messages
- 9,922
- Office Version
- 365
- Platform
- Windows
Hi,
I found the following code to report cell changes:
Workbook event:
And procedure:
This was working on Friday, when it would undo the action but not today and I've made no code changes, but the output shows the old value and new value as the new value - due to the .undo not working as far as I can tell.
Any ideas/suggestions?
TIA,
Jack
I found the following code to report cell changes:
Workbook event:
Rich (BB code):
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Parent.Name <> wSummary.Name Then Exit Sub
Application.EnableEvents = False
LogChange Target
Application.EnableEvents = True
End Sub
Rich (BB code):
Public Sub LogChange(ByRef rTarget As Range)
Dim vNewValues As Variant
Dim vRecords As Variant
Dim msg(1 To 3) As String
Dim rng As Range
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
On Error GoTo ExitProc
With rTarget
If .CountLarge = 1 Then
Set rng = Selection
msg(2) = .Value
On Error Resume Next: Application.Undo: On Error GoTo ExitProc
msg(1) = .Value
.Value = msg(2)
rng.Select
Else
On Error Resume Next
msg(3) = Application.CommandBars("Standard").FindControl(ID:=128).List(1)
On Error GoTo ExitProc
msg(1) = "Operation: " & msg(3)
msg(2) = "Changed: " & .CountLarge & " cells."
End If
vRecords = Log_Sheet_Headers(rTarget, msg)
With wLog.Cells(Rows.Count, 1).End(xlUp)(2).Resize(1, UBound(vRecords) - LBound(vRecords) + 1)
.Value = vRecords
.EntireColumn.AutoFit
End With
End With
Erase vNewValues: Erase vRecords: Set rng = Nothing
ExitProc:
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Any ideas/suggestions?
TIA,
Jack
Last edited: