Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default restrict user to enter 5 digits only

How can we restrict users to enter 5 digits only in a userform textbox?

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default restrict user to enter 5 digits only

Hi,

I simple way is to set the maxlengrh property to 5. Right click the textbox,
properties abd you'll see the propery of maxlength.

Mike

"sam" wrote:

How can we restrict users to enter 5 digits only in a userform textbox?

TIA

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,276
Default restrict user to enter 5 digits only

Hi Tia,
Go to visual basic, view object, position in the textbox you want to enter
the limit, then choose Categorized, under Behavior look into MaxLength and
enter 5 there

"sam" wrote:

How can we restrict users to enter 5 digits only in a userform textbox?

TIA

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default restrict user to enter 5 digits only

You have to check yourself.

Option Explicit
Private Sub CommandButton1_Click()
MsgBox Me.TextBox1.Value
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim iCtr As Long
Dim myStr As String
Dim OkValue As Boolean

myStr = Me.TextBox1.Value

OkValue = True
If Len(myStr) < 5 Then
OkValue = False
Else
For iCtr = 1 To 5
If IsNumeric(Mid(myStr, iCtr, 1)) Then
'keep looking
Else
OkValue = False
Exit For 'stop looking
End If
Next iCtr
End If
Cancel = Not (OkValue)
End Sub
Private Sub UserForm_Initialize()
'the cancel button
'allows the user to hit that button even if
'the entry in the textbox is invalid
Me.CommandButton2.TakeFocusOnClick = False
End Sub


sam wrote:

How can we restrict users to enter 5 digits only in a userform textbox?

TIA


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default restrict user to enter 5 digits only

thanks a lot, this worked out great. we can set the max value from property
box, but do you know how we can set min values?

"Mike H" wrote:

Hi,

I simple way is to set the maxlengrh property to 5. Right click the textbox,
properties abd you'll see the propery of maxlength.

Mike

"sam" wrote:

How can we restrict users to enter 5 digits only in a userform textbox?

TIA



  #6   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default restrict user to enter 5 digits only

thanks a lot, this worked out great. we can set the max value from property
box, but do you know how we can set min values?

"Eduardo" wrote:

Hi Tia,
Go to visual basic, view object, position in the textbox you want to enter
the limit, then choose Categorized, under Behavior look into MaxLength and
enter 5 there

"sam" wrote:

How can we restrict users to enter 5 digits only in a userform textbox?

TIA

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
restrict user in excel to numbers below 100 Caroline Excel Worksheet Functions 2 February 25th 08 09:03 PM
Not able to enter more than 15 digits in a cell. Mike Excel Discussion (Misc queries) 0 January 19th 07 03:31 PM
How do I enter a SSN but only display the last four digits? Caspar Excel Discussion (Misc queries) 1 August 5th 06 01:57 AM
Restrict User to specific cell [email protected] Excel Discussion (Misc queries) 3 April 24th 06 01:59 AM
Restrict User Input Sala[_2_] Excel Programming 7 May 4th 04 07:39 PM


All times are GMT +1. The time now is 11:25 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"