Forum

Userform Data Valid...
 
Notifications
Clear all

Userform Data Validation

2 Posts
2 Users
0 Reactions
82 Views
(@sovereignty9)
Posts: 1
New Member
Topic starter
 

Hi Phil,

 

I have recently come across your user form deleting and inserting template. I have tried to adapt it for my needs but now I'm struggling for it to allow just two of the text boxes to allow non numeric data.

Is there any chance you could take a look and see if your able to see where I'm going wrong.

 

Many Thanks

 

Sovereignty9

 
Posted : 28/06/2017 8:40 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi,

You can control everything the user does in that form.

Check our file for an example.

If you want to have a specific data format for a textbox, use a pattern like:

 

Private Sub Accommodation_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim X As String
 
X = Accommodation.Value

If Not X Like "###-??-###" Then
     Cancel = True
End If
       

End Sub

The pattern "###-??-###" means that first and last 3 chars are numeric, the middle ?? can be any 2 chars. You can build your own pattern, use the * wildcard if necessary (* will allow any char, can be used like: "233*", meaning that the text should start with 233, followed by any chars)

See also an example of how to control other types of data in the second file attached.

 
Posted : 30/06/2017 8:01 am
Share: