LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't input anything I type on Excel. What can I do? Nothing p. nakalkn Excel Worksheet Functions 2 April 19th 12 12:17 AM
error 13 type mismatch input box cluckers Excel Discussion (Misc queries) 1 October 28th 09 07:01 PM
Exit Code Upon Cancel On Type 8 Input Box FARAZ QURESHI Excel Discussion (Misc queries) 2 March 31st 08 09:22 AM
How to modify the code for different type of input? Eric Excel Worksheet Functions 1 September 1st 07 03:58 PM
How to modify the code for different type of input? Eric Excel Discussion (Misc queries) 2 September 1st 07 12:30 AM


All times are GMT +1. The time now is 08:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"