I have in my Excel VBA project, a combobox which uses a range of cells as it's list of items. I have used a filter in it, so that whenever a value is entered, the list shrinks down to the items containing the string, and dropdown list is shown. However, the problem appears, when the dropdown is shown, the navigation keys can't be used to scroll within the items. As soon as the down key is pressed the dropdown list will be filtered again.
I guess its happening because the down key while focusing on the items, is also selecting it. Hence, the combobox_change event is called automatically.
Is there a way so that I can stop the keydown event automatically selecting an item, but only scroll through them?
Edited Answer:
Now having built my own sheet and worked with these ideas, ironically
Application.EnableEvents
only helps in certain situations because theCombobox_Change()
event still fires with events disabled (or seems to be the case, at least). The basic idea that I found involved manipulating theKeyCodes
and setting flags. My example below involves using aComboBox
calledTempCombo
and running code after theTempCombo_KeyDown()
event within the VBA for the sheet (I have trimmed my stuff down for example purposes):I used the
Abort
variable as a flag in theTempCombo_Change()
to prevent both multiple firings of the event code, and allow keys to not change the text result of the linked cell, preventing my dynamic range from updating. Make sure both subroutines are on the sheet where theComboBox
is!So that is a skeleton of what I did for this, if someone finds a problem let me know, but I hope this can help someone.