Hello,
pleas, how I could exclude changes of blank value? I no need log, when emty cell is changed.
Thank you!
pleas, how I could exclude changes of blank value? I no need log, when emty cell is changed.
Thank you!
Code:
Dim PreviousValues As Variant
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Store current values of all cells
Application.EnableEvents = True
PreviousValues = Me.UsedRange.Value
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim LR As Long
Dim c As Range
On Error Resume Next
Application.EnableEvents = False
If Target(1).Value <> PreviousValues(Target(1).row, Target(1).Column) Then
With Sheets("LogSheet")
For Each c In Target
LR = .Cells(Rows.Count, "A").End(xlUp).row + 1
.Cells(LR, "A").Value = ActiveSheet.Name & "!" & c.Address
.Cells(LR, "B").Value = Now
.Cells(LR, "C").Value = Environ("UserName")
.Cells(LR, "D").Value = PreviousValues(c.row, c.Column)
.Cells(LR, "E").Value = c.Value
Next c
End With
End If
Application.EnableEvents = True
End Sub