View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Big Chris[_30_] Big Chris[_30_] is offline
external usenet poster
 
Posts: 1
Default Defining input box data type?

Hi,

I'm running the macro below and everything seemed OK.....I enter th
wrong numberic code I get a "Number is incorrect" message and it stops
I enter the right numeric code and it and goes on and runs anothe
macro.
Problem is, if I the user enters an incorrect alph code (e.g. ABCD) i
bombs out and shows the error as.... "Run-Time error 13 - Typ
Mismatch".
Could anyone please tell me how I can avoid this from happening, an
instead get it to produce the same "Number is incorrect" message?

When the macro interupts it highlights the line
'If CLng(myNum) = ActiveCell.Value Then'.

Many thanks!!

Chris

---------------------------------------------------------------------------

Sub CommandButton1_Click()

myNum = InputBox("Please enter your 8 digit validation code. :", "Ente
Code")

If myNum = "" Then
Exit Sub
End If

Sheets("Sheet1").Select
Range("a3").Select

If CLng(myNum) = ActiveCell.Value Then
Application.OnTime Now, "RunAnotherMacro"

Else
MsgBox "Number is incorrect"

End If

Sheets("Sheet1").Select
Range("A1").Value = myNum

End Su

--
Message posted from http://www.ExcelForum.com