-
Solved: Combobox: Enter, Tab and Backspace Keys Not Triggering Keypress Events
Just creating a simple form that will allow me to select a name from a list located on another sheet. I load the combo box with the values in a named range. When I start to type the name the combo autofills based on my partial selection. When I attempt to capture the "Enter" key via the "_Keypress" sub no event is triggered. How can I capture the Enter, Tab and Backspace Keys?
[vba]Public Sub prepComboBox()
Dim arange As Range
fillComboBox Sheet1.ComboName, ThisWorkbook.Names("Headcount").RefersToRange
End Sub
Public Sub fillComboBox(aCombobox As ComboBox, arange As Range)
Dim aRow As Range
Dim index As Integer
index = 0
aCombobox.Clear
For Each aRow In arange.rows
If index <> 0 Then
aCombobox.AddItem (aRow.Cells(1, 2).value)
End If
index = index + 1
Next aRow
End Sub[/vba]
This code is in the sheet with the combo box. (Triggers for every other key but 13
[vba]Private Sub ComboName_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
MsgBox "Key pressed"
End Sub[/vba]
-
Use the KeyDown or KeyUp events.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules