View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sisilla[_2_] Sisilla[_2_] is offline
external usenet poster
 
Posts: 34
Default 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