hi yall
i have below code which mostly works except it also asks confirmation for empty cells, i want it to ignore the rule for blank cells where value are being set for first time, is this doable?
i have below code which mostly works except it also asks confirmation for empty cells, i want it to ignore the rule for blank cells where value are being set for first time, is this doable?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oldValue As Variant
Dim newValue As Variant
Dim userResponse As Integer
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
If Not IsEmpty(Target) Then
newValue = Target.Value
Application.Undo
oldValue = Target.Value
If oldValue <> newValue Then
userResponse = MsgBox("Do you want to change the value?", vbYesNo + vbQuestion, "Confirm Change")
If userResponse = vbNo Then
Target.Value = oldValue
Else
Target.Value = newValue
End If
End If
End If
Application.EnableEvents = True
End Sub