VBA & Macro Problems

Use Arrow and Enter Keys with an Excel VBA ComboBox

Algirdas JasaitisAlgirdas Jasaitis Nov 14, 2026 868 views

Question details

Enable keyboard navigation and selection in an Excel VBA ComboBox.

Product
Microsoft Excel VBA
Device & OS
not provided
Scenario
A UserForm ComboBox contains a drop-down list that the user wants to navigate with the Down Arrow and confirm with Enter.
Observed behavior
The list opens, but the user currently needs a mouse to select an item.
Before you start

Confirm that the ComboBox is on a VBA UserForm and check its name in the Properties window. The example uses ComboBox1 and sample list items; replace them with your control name and values.

Solution 1Recommended

Handle Down Arrow and Enter in the UserForm ComboBox

Use a KeyDown event to move through the list and confirm the selected item without a mouse.

This example populates the list once when the UserForm opens. Down Arrow advances through the items, and Enter hides the form when an item is selected.

1
Open the UserForm code

In Excel, press Alt+F11 to open the VBA editor. In Project Explorer, find your UserForm, right-click it, and select View Code.

2
Initialize the list

Add this procedure to the UserForm code module, replacing the sample values as needed: Private Sub UserForm_Initialize() With Me.ComboBox1 .Clear .AddItem "Option 1" .AddItem "Option 2" .AddItem "Option 3" End With End Sub

3
Add keyboard handling

In the same UserForm code module, add: Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) With Me.ComboBox1 Select Case KeyCode Case vbKeyDown If .ListCount > 0 Then .DropDown If .ListIndex < .ListCount - 1 Then .ListIndex = .ListIndex + 1 End If End If KeyCode = 0 Case vbKeyReturn KeyCode = 0 If .ListIndex >= 0 Then Me.Hide End Select End With End Sub

4
Test the controls

Run the UserForm, click or Tab to ComboBox1, then press Down Arrow to advance and Enter to confirm. Read ComboBox1.Value from the calling code after the form is hidden.

Handle Down Arrow and Enter in the UserForm ComboBox
Adapt the confirmation action: Me.Hide closes the visible form without unloading it, so the calling code can read the selection. Replace it with your own confirmation action if needed, and unload the form when it is no longer required.
Free Microsoft Office alternative

Work with Excel files in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for common Excel formats, making it easy to move everyday spreadsheet work. Check macro compatibility for your edition before migrating VBA-dependent workbooks.

Open and edit common Excel formats, including XLSXUse a familiar spreadsheet interface for everyday workbook tasksReview VBA-dependent ComboBox workflows before migrating themWork with a free, lightweight office suite
QA img-9

Frequently Asked Questions

Where should I put the ComboBox KeyDown code?

In the VBA editor, right-click the UserForm in Project Explorer and select View Code. Place the ComboBox1_KeyDown procedure in that UserForm's code module, and use your actual ComboBox name.

Why should I populate the list in UserForm_Initialize?

UserForm_Initialize runs when the form is loaded, so it is a suitable place to set up list items once. Reassigning ListFillRange in the Change event can repeatedly reset the list as the selection changes.

What happens if I press Enter without selecting an item?

In the example, the form stays open because ListIndex is -1 when no item is selected. Press Down Arrow to select an item, then press Enter.

How can I use the selected value after pressing Enter?

After the UserForm is hidden, read its ComboBox1.Value from the calling VBA procedure. Then unload the form when you no longer need it.