Private Sub Combobox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim idx As Long
idx = ComboBox1.ListIndex
If idx = -1 Then
MsgBox "Invalid seal number selected/entered"
Cancel = True
End If
End Sub
With a combobox if the user enters a value that's not on the list then the ListIndex property of the combobox will be -1, something that is easily to check.
Code:Private Sub Combobox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Dim idx As Long idx = ComboBox1.ListIndex If idx = -1 Then MsgBox "Invalid seal number selected/entered" Cancel = True End If End Sub
With a combobox if the user enters a value that's not on the list then the ListIndex property of the combobox will be -1, something that is easily to check.
Code:Private Sub Combobox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Dim idx As Long idx = ComboBox1.ListIndex If idx = -1 Then MsgBox "Invalid seal number selected/entered" Cancel = True End If End Sub