Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Bob :)
"Bob Phillips" wrote: You cannot set formatr to textboxes as you can with cells (unfortunately), and there is no built-in masking either, so you have to either build it yourself, or check after the event. For instance, With Me.TextBox1 If Not IsDate(.Text) Then .SelStart = 0 .SelLength = Len(.Text) .SetFocus MsgBox ("Please enter date as dd-mm-yyyy") End If End With For percentages, assuming not greater than 100, you can try Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) With Me.TextBox1 Debug.Print .Text, KeyAscii Select Case KeyAscii Case 48 To 57 'numbers If (Len(.Text) = 2 And (.Text < "10" Or KeyAscii < 48)) Or _ Len(.Text) = 3 Then Beep KeyAscii = 0 End If Case Else 'Discard anything else Beep KeyAscii = 0 End Select End With End Sub -- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) "Matthew Balch" wrote in message ... Dear All, I have a user form that has several text boxs that require input. How do I format these boxes / control what the user inputs into them. ie on the change sub of the text box I need a control that says If textbox1.numberformat = "dd-mm-yyyy" Then Next Else MsgBox("Please enter date as dd-mm-yyyy") Furthermore I would also like to format a text box so that percentages can be entered. At present I have had to highlight to the user that they need to be entered as a decimal. Is there any way around this? Thanks in advance And thanks for all your previous help. Starting to get the basics of this and put together some 'good' templates. Kind Regards Matthew Balch |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Forcing User inputs | Excel Discussion (Misc queries) | |||
Locking Cells when user inputs data | Excel Discussion (Misc queries) | |||
Extend Border As User Inputs New Rows | Excel Discussion (Misc queries) | |||
Controlling user environment | Excel Programming | |||
If the user inputs lower case y/n answer How do I convert automat. | Excel Discussion (Misc queries) |