![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
|
Hi,
Is there a quick code that i can use to make sure that a value in a text box on my userform is a number (0-9), and if its not, give a message or something? Thanks |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try the following code:
If Application.WorksheetFunction.And(textbox1.Value >= 0, textbox1.Value <= 9) = False Then MsgBox "Incorrect value" Replace textbox1 with the name of your textbox.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
|
Al, thanks for the quick response, but actually I worded my question wrong. I want the value to be a number, but it may have multiple digits...so it could be 12345 etc. I'm just trying to keep everying except numbers out of the field. How would i do that?
|
|
|
|
|
|
#4 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
If Not Application.WorksheetFunction.IsNumber(textbox1.Value) _
Then MsgBox "Make it a number please. Merci." _________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-02 15:41 ] |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Stockton, California
Posts: 281
|
Thank you very much
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|