I am trying to do an input validation (Only Accept Numeric Value), however the code below does not seem to work properly. Can someone please shed a light.
Upon entering non-numerical Value, the MsgBox is somehow skipped and the sub routine goes straight to Error:
Sub Check()
Dim A As Integer
On Error GoTo Error
Do
A = InputBox("Enter A Numerical Value:")
If IsNumeric(A) Then
Exit Do
Else
MsgBox ("Please Enter A Numerical Value!")
End If
Loop
Exit Sub
Error:
MsgBox "An Error Has Occured!"
End Sub
Application.InputBoxand specify theType?Dim A As String- Then useIsNumericA(because you declared A asIntegerand that can't hold a string)- so your code goes directly to the error handler.