Test if WorkSheet ComboBox list is open
Hello All,
I have a combo box on a worksheet. I use the DropDown method to open the list on the Change event and the KeyDown event to click on a button if the ENTER key is pressed. Private Sub cbJobField_Change() cbJobField.DropDown End Sub Private Sub cbJobField_KeyDown(ByVal KeyCode As MSForms.ReturnInteger) If KeyCode = vbKeyReturn Then btnFind_Click End If End Sub I would like to change cbJobField_KeyDown so that when the ENTER key is pressed, if the combo box list is open, it is closed, but if it is already closed, btnFind_Click is executed. I expect the code would look similar to the following: Private Sub cbJobField_KeyDown(ByVal KeyCode As MSForms.ReturnInteger) If KeyCode = vbKeyReturn Then If cbJobField.DroppedDown = True Then Application.SendKeys("{ESC}") Else btnFind_Click End If End Sub Is this at all possible? If not, does anyone have any ideas for a workaround? I appreciate any help. Thanks! Sisilla |
Test if WorkSheet ComboBox list is open
Workaround:
Private Sub cbJobField_Change() cbJobField.DropDown Sheets("Links").Range("DropDownOpen").Value = "True" End Sub Private Sub cbJobField_KeyDown(ByVal KeyCode As MSForms.ReturnInteger) If KeyCode = vbKeyReturn Then If Sheets("Links").Range("DropDownOpen").Value = "True" Then Sheets("Links").Range("DropDownOpen").Value = "False" ActivateComboBox cbJobField Else btnFind_Click End If End If End Sub Sisilla wrote: Hello All, I have a combo box on a worksheet. I use the DropDown method to open the list on the Change event and the KeyDown event to click on a button if the ENTER key is pressed. Private Sub cbJobField_Change() cbJobField.DropDown End Sub Private Sub cbJobField_KeyDown(ByVal KeyCode As MSForms.ReturnInteger) If KeyCode = vbKeyReturn Then btnFind_Click End If End Sub I would like to change cbJobField_KeyDown so that when the ENTER key is pressed, if the combo box list is open, it is closed, but if it is already closed, btnFind_Click is executed. I expect the code would look similar to the following: Private Sub cbJobField_KeyDown(ByVal KeyCode As MSForms.ReturnInteger) If KeyCode = vbKeyReturn Then If cbJobField.DroppedDown = True Then Application.SendKeys("{ESC}") Else btnFind_Click End If End Sub Is this at all possible? If not, does anyone have any ideas for a workaround? I appreciate any help. Thanks! Sisilla |
All times are GMT +1. The time now is 06:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com