Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validating Entry into Textbox
Hi all,
I've created a custom userform with many textboxes in Excel 2000. I'd like to validate/limit the values that can be entered into these text boxes. If the entered value is outside of the desired range, it should prevent the user from continuing. This is what I have so far: Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Set ControlName = TextBox1 Call CheckIntEntry(ControlName, Cancel) End Sub Sub CheckIntEntry(ControlName, Cancel) If ControlName.Value < 0 Or ControlName.Value 999 Then Cancel = True MsgBox ("Entry must be between 0 and 999.") Else Cancel = False End If End Sub This does what I want, but would have to be setup for the 50+ textboxes. Is there a better way to limit entry? Can a property be set for each textbox that sets an allowable entry range? Thanks in advance for your help. -Brad |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Validating Entry into Textbox
If you want to use the exit event, that would be the way.
-- Regards, Tom Ogilvy "Brad" wrote in message ... Hi all, I've created a custom userform with many textboxes in Excel 2000. I'd like to validate/limit the values that can be entered into these text boxes. If the entered value is outside of the desired range, it should prevent the user from continuing. This is what I have so far: Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Set ControlName = TextBox1 Call CheckIntEntry(ControlName, Cancel) End Sub Sub CheckIntEntry(ControlName, Cancel) If ControlName.Value < 0 Or ControlName.Value 999 Then Cancel = True MsgBox ("Entry must be between 0 and 999.") Else Cancel = False End If End Sub This does what I want, but would have to be setup for the 50+ textboxes. Is there a better way to limit entry? Can a property be set for each textbox that sets an allowable entry range? Thanks in advance for your help. -Brad |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calculate Textbox value based on another textbox value | Excel Discussion (Misc queries) | |||
Validating entry in ComboBox | Excel Discussion (Misc queries) | |||
restrict entry in a textbox to a range of values | Excel Programming | |||
Highlighting or Selecting TextBox entry | Excel Programming | |||
UserForm TextBox to ActiveSheet TextBox over 256 characters | Excel Programming |