Use VBA code to display message if combobox selection not in list

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When using combo box to display drop-down list, users can actually type in
any value they want...not good for what I need. A feasible fix for this is
to verify that the value typed in the combo box is in a list...if it isn't
display a message that says Try Again.

Based on the list below, what would the VBA code look like that says if
combo box value is not in list then give error message?

List: Monday, Tuesday, Wednesday
 
Hi,

It won''t convert the combobox. Just change its behavior.

But anyway, can use MatchRequired and then If MatchFound on change
event.

TJ :)
 
dim myArr as Variant
myArr = array("Monday","Tuesday","Wednesday")

if iserror(application.match(me.combobox1.value,myarr,0)) then
'not a match, the board goes back
else
'do what you want
end if

But changing the .style is too easy to ignore.
 
Back
Top