I have a sheet where the user must enter a value in the range("A3:A12"). See enclosed image.
If he accidentally deletes one of these cells then VBA traps the error, see the code below.
But when he deletes MORE THAN ONE one cell then error 13 "type mismatch".
Any ideas ?
If he accidentally deletes one of these cells then VBA traps the error, see the code below.
But when he deletes MORE THAN ONE one cell then error 13 "type mismatch".
Any ideas ?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim col_A_rng As Range
Set col_A_rng = Range("A3:A12")
If Target.Count > 0 And Not Application.Intersect(Target, col_A_rng) Is Nothing Then
If Target.Value = "" Then
Target.Select
Application.EnableEvents = False
MsgBox ("you must enter a value"), vbCritical
Application.Undo
Application.EnableEvents = True
End If
End If
End Sub
Attachments
Last edited by a moderator: