TextBox validation

Whistler

Board Regular
Joined
Jul 14, 2011
Messages
61
Hello Guys,

I have a UserForm where users adding sdata to the table via a textboxes.
One of the textBox can contain only names which are in second table.
How to validate this TextBox?

I need something like below:

If Table containts then return true

Thanks

PS. Im new in VBA, pleas be patient

Thanks very much
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
For clarificatrion, I managed to write method which will prompt message box and set focus if false is return, and here I have a problem.

I need:
If Table contain TextBox.Value then return true

Thanks
 
Upvote 0
I search few forums and I cannot find this anywhere, I only found numbers or email validation. Anyone?
 
Upvote 0
I have managed to resolve it, but I am having antoher problem, Excel is finding Name in tables but only if I inpit to the textBox name without space between name and surname. Any idea?

Private Sub NameBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim ws3 As Worksheet
Dim aTable As Range
Set ws3 = Worksheets("Names")
Set aTable = ws3.Range("A:A")
Set c = aTable.Find(NameBox.Value)
If Not c Is Nothing Then
MsgBox "The name is not valid. Please check for taping mistakes or re-enter."
Cancel = True
With NameBox
.SetFocus
End With
End If
End Sub

Thanks for any help
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,706
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top