User form data validation

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
194
Morning all

As part of a user form I am developing the user has to enter a seal number , but it has to be on the seal list .
The list has 3000 numbers ,
How can I make sure the user only picks a number off the list ?
 
It shouldn't, how did you populate the combobox?

Are you entering the value(s) manually or by selection via the dropdown?

If I select them from the list all works well.
But if I enter a value manually which is in the list I get your error message.

The Combobox is loaded like this:


ComboBox1.List = Range("E1:E3000").Value
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Are there any trailing/leading spaces in the range E1:E3000?
 
Upvote 0
And you are just entering 1, 2, 3 or whatever?
 
Upvote 0
And to just assure you here is your script I'm using
It's actually Combobox9
And list loads into combox9

Code:
Private Sub ComboBox9_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim idx As Long
    
    idx = ComboBox9.ListIndex
   If idx = -1 Then
       MsgBox "Invalid seal number selected/entered"
       Cancel = True
   End If
   
   Cells(1, 8).Value = ComboBox9.Value
End Sub
 
Upvote 0
Manualy , just need to check the number is valid ( on the list )
The list is on the same sheet at the moment but can be stored anywhere
 
Upvote 0
Your proving very little information here.
I asked in post #3 :

In post 3 I asked this question and you never answered it.
What is the name of the Combobox?
Where is this list of 3,000 numbers?

And in your last post you said:

The list is on the same sheet at the moment but can be stored anywhere

You did not give me the name of the Combobox and when I ask where is this list I need an exact location. You only said on my sheet. There are millions of places on your sheet.

And I guess from what your saying you have not loaded this list into the Combobox.

So if you enter some number into the combobox you want the script to search for that value from a list of values somewhere on your sheet to see if that is a valid number.

Your lack of answering specific questions is not helping and I can not provide a answer till you answer those specific questions with specific details
 
Upvote 0
No ! just a simpl list of numbers no spaces and the list will not change

Thanks for taking time to help
 
Upvote 0
Sorry I am not trying to make it difficult , I appreciate any help.

So start again , As part of my form the user has to enter a "Seal" number , this has to be in a range - 7647001 - 7650000.
And after talking to the end user they do not want a combo box but make the user enter the "seal" number and if not in the range to show an error message.
Aklo not to allow a "seal" number that has been used.
I said the list is on the same sheet as it does not realy matter where it is but I did state that it was E1 to E3000.

Hope this explains things a bit better, again appologies for not being clear.
 
Upvote 0

Forum statistics

Threads
1,224,829
Messages
6,181,222
Members
453,024
Latest member
Wingit77

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