Combobox - add manual entry to future list

  • Thread starter Thread starter cornishbloke
  • Start date Start date
C

cornishbloke

Another query,

When a user enters a manual entry into the combobox on my userform
want the userform to ask if this entry should be added to the drop-dow
list for future use.

I can manage most of this but I don't know what the statement would b
for determining if the manual entry is in the existing list or not.

if combobox1.value = 'one not in source list' then
call userform2 etc

Can anyone help
 
Same as any other type of comparison. You would loop through the list and
see if the value of the combobox matches any entry in the list. There is
not built in setting or attribute that will tell you that information.

You can also avoid a loop by using the worksheet Match function.
 
Hi Tom,

This would be the first time that I've needed to use a loop, so I'm not
sure how to do what you suggest. Assuming my list is in cells A1:A10
and is named "ContList" how would I use loop through to check if the
value of ContCombobox matches any in this range?

Thank you for your patience!
 
Dim cell as range
Dim bMatch as boolean
Dim ans as Variant
for each cell in Range("ContList")
if lcase(trim(cell.value) = me.Combobox1.Value then _
bMatch = True
exit for ' found, no need to continue checking
End if
Next
if not bMatch then
ans = msgbox( "Add " & me.Combobox1.Value & " to list?", vbYesNo)
if ans = vbYes then
' add to list
end if
End if
 
Back
Top