ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need Input Box to only Accept Numeric Values (https://www.excelbanter.com/excel-programming/382534-need-input-box-only-accept-numeric-values.html)

[email protected]

Need Input Box to only Accept Numeric Values
 
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!


[email protected]

Need Input Box to only Accept Numeric Values
 
Sorry one other note....This is VBA for Excel.


On Feb 3, 11:45 am, wrote:
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!




zz

Need Input Box to only Accept Numeric Values
 
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

--

---
Zz

wrote in message
oups.com...
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!




Tom Ogilvy

Need Input Box to only Accept Numeric Values
 
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

--
Regards,
Tom Ogilvy



wrote in message
ps.com...
Sorry one other note....This is VBA for Excel.


On Feb 3, 11:45 am, wrote:
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!






VBA Noob

Need Input Box to only Accept Numeric Values
 
Could you try

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

VBA Noob


On 3 Feb, 17:45, wrote:
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!




Kari J Keinonen[_2_]

Need Input Box to only Accept Numeric Values
 
Hi!

Try this one

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

Regards
Kari J Keinonen

JMB

Need Input Box to only Accept Numeric Values
 
if isnumber(X) then

I think you mean isnumeric(x) or application.isnumber(x)


"zz" wrote:

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

--

---
Zz

wrote in message
oups.com...
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!






All times are GMT +1. The time now is 01:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com