I have a code that works fine, if I click on a cell and click delete its fine; however if I highlight more than one cell and press delete it triggers the messagebox in the code and sends the message in a loop.
Note: in some cases it doesnt throw the messagebox, it actually gives a run time error, I am not seeing the error now but it refers to type mismatch.
Can anyone tell me what is causing that?
below is the code i am having the issue with:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("$a$8:$a$3000")) Is Nothing Then
On Error Resume Next
With CreateObject("vbscript.regexp")
.Global = True
.Pattern = "[^0-9C.]"
If .test(Target.Value) Then
MsgBox "The ACCOUNT number field is restricted to numbers only (0 - 9)"
Target.Clear
Target.Select
End If
End With
End If
Bookmarks