Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
open worksheet with a macro (combobox) | Excel Programming | |||
squashed test in combobox | Excel Programming | |||
squashed test in combobox??? | Excel Programming | |||
ComboBox list reliant on the entry from a different ComboBox | Excel Programming | |||
List Open Workbooks in a combobox | Excel Programming |