I have an ActiveX Combobox control on a worksheet and this is the _Change
event code
Private Sub ComboBox1_Change()
Me.ComboBox1.ListFillRange = "ItemSearch"
Me.ComboBox1.DropDown
End Sub
When I use keyboard up/down key to move through the list it automatically quits Excel.
Does anyone know the solution to this problem? I basically want a dynamic ComboBox.
I have solved this by setting ListFillRange only if no item is selected, ie
This solves the error and is desirable as (at least in my case) range can only have 1 item when something is selected. So, user types for autocomplete, but when he starts using arrows he can choose from filtered so far values.
Complete example is available there . Unlike in this often mentioned example as user types it filters out entries which don't match current input
You are forcing Combobox's possible values to update when you change the selected option,
that is why it's crashing.
You can try to keep
Me.ComboBox1.DropDown
in that event.But the
.ListFillRange
should be in another event :If you're attempting to have a kind of AutoComplete behavior, you can use a built-in property :
MatchEntry
property0 - fmMatchEntryFirstLetter