In the example below, the statement following "Else" is executed before the
statements following "Application.Undo".
Can someone explain why, and the proper way to do this?
Thanks,
Bernie
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim TargetRow, NumberRows, CellOnOpen, CurrentRow, Tier
If Target.Column <> 1 Then If Target.Column <> 3 Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
ActiveSheet.Unprotect
CurrentRow = ActiveCell.Row
If Target.Column = 1 And CurrentRow = 1 And Selection.Value = "" Then
Application.Undo
MsgBox ("You may not delete this row, but you may modify as
necessary")
Cells(CurrentRow, 1).Select
Exit Sub
Else
MsgBox ("Why is this being executed when I DELETE cell A1?")
End If
End Sub
Bookmarks