Need Input Box to only Accept Numeric Values

  • Thread starter audreyanderson1
  • Start date
A

audreyanderson1

Help! I need a way to only allow numeric values to be accepted by an
input box. My code starts with


inputNum = InputBox("Please enter the part number", "Part Number",
0)
x = Val(inputNum)


I'm using a vlookup to make sure a input number is valid, but not sure
how to go about it if letters were input. The program should not go
any further if an alpha string is entered. How do I check for this??

Thank you!
 
Z

zz

see if this work:


x=inputbox("the prompt","the title")
if isnumber(X) then
all_correct
else
start_from_beginning_and_this_time_write_it_well
end if
 
T

Tom Ogilvy

There are two different inputboxes. Use the Excel Inputbox instead:

Sub abc()
Dim x As Long

x = Application.InputBox("Please enter the part number", _
"Part Number", 0, Type:=1)

End Sub
 
V

VBA Noob

Could you try

inputNum = Application.InputBox("Please enter the part number", "Part
Number", Type:=1)

VBA Noob
 
G

Guest

Hi!

Try this one

inputNum = Application.InputBox("Please enter the part number", _
"Part Number", , , , , , 1)

Regards
Kari J Keinonen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top