Numbers

J

Jevul

Hello,

I am trying to figure out a way to prevent users from
entering a "not real" number into a text box. I tried to
ues an If statement.... If Not Isnumeric......
This doesn't seem to work. I had a user input "2345.45-"
with no error but excel igneroed the number in a
calculation. My users are bound to make many mistakes
and I would like to catch them at the time.

Thanks
 
B

Bob Flanagan

Try using Application.IsNumber()

Even better is to set a cell to the text box value and then test the value
of the cell to see if the above is true. Why? Try 100%. If in a text box,
it is not a number. But if written to a cell, it is a number.

Bob Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
D

Doug Glancy

Bob,

Another great tip from this ng. I knew about Application.IsNumber, but your
point about setting it to a cell is new to me. Now, if I can just find a
corner of my brain to stuff it in...

Thanks,

Doug Glancy
 
J

Jevul

Thanks, works perfectly!
-----Original Message-----
Try using Application.IsNumber()

Even better is to set a cell to the text box value and then test the value
of the cell to see if the above is true. Why? Try 100%. If in a text box,
it is not a number. But if written to a cell, it is a number.

Bob Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel




.
 
Top