Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
By using application.inputbox and type:=1, you're telling excel that they have
to enter a number. This means that your code doesn't have to do anything to check to see if the entry is a number. If you don't want that warning message, then you can use: myNum = inputbox(Prompt:="enter a number") But now all the validation will be your responsibility. ArthurJ wrote: I want the user to input a number. I want to handle the three possible situations: 1. User enters number 2. User clicks Cancel 3. User enters nothing and clicks OK I am having trouble with the third possibility, where the user enters nothing. Below is some of the code I have now: Sub GetNumber Dim myNum As Variant On Error Resume Next 'This line seems to have no effect. myNum = Application.InputBox(Prompt:="Enter a number", Type:=1) 'If user enters nothing and clicks OK, Excel generates an info box about 'entering an incorrect formula. But it is NOT a VBA error so cannot be trapped 'with normal methods. If myNum = False Then MsgBox ("Cancel was chosen. Macro will end.") Exit Sub Else MsgBox (myNum) End If End Sub Thank you, Art -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help with Application.InputBox(,,,,,8) | Excel Programming | |||
Application.InputBox | Excel Programming | |||
Inputbox and Application.InputBox | Excel Programming | |||
Application.DecimalSeparator usage. | Excel Programming | |||
application.inputbox | Excel Programming |