Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
Validating entry in ComboBox LAF Excel Discussion (Misc queries) 0 September 29th 05 08:45 PM
restrict entry in a textbox to a range of values Dillonstar[_3_] Excel Programming 5 October 30th 03 05:00 PM
Highlighting or Selecting TextBox entry Gus Gazepis Excel Programming 3 September 8th 03 12:01 AM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 03:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"