Forum Discussion
VBA Drop Down List
You can set the ListFillRange utilizing an event called GotFocus so that it doesn't set the ListFillRange each time you type in the ComboBox.
Private Sub ComboBox1_GotFocus()
ComboBox1.ListFillRange = "DropDownListv1"
End Sub
What do you suggest can be added?
- Subodh_Tiwari_sktneerSep 06, 2019Silver Contributor
Are you having any other events like KeyPress or KeyDown etc?
If I insert a dummy ComboBox and have the Change and GotFocus events, I can use my up and down arrow keys to scroll up and down.
Why not upload the file in question after removing the sensitive data if any?
- AnggieSep 10, 2019Copper ContributorHi, can you explain how the dummy box works? I have typed in another code:
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode <> 40 And KeyCode <> 38 Then
ComboBox1.ListFillRange = "DropDownListv1"
Me.ComboBox1.DropDown
Else
KeyCode = 0
End If
End Sub- Subodh_Tiwari_sktneerSep 10, 2019Silver Contributor
That code is the culprit.
Basically with that code, you are asking the code to check, if UP arrow key (KeyCode-38) or Down arrow key (KeyCode-40) is pressed, don't do anything and disable those keys when you say KeyCode = 0 in the Else clause.
What's the need of that code? Why are you having same code with multiple events?
Delete this KeyDown event code and your ComboBox will start working.