Home > Software design >  On cell "A1" click then ComboBox11 opens
On cell "A1" click then ComboBox11 opens

Time:12-11

Cell ("A1") displays the value of an adjacent cell ("B1") which is the linked cell to (Active X) ComboBox11.

When clicking on "A1", I would like ComboBox11 to open/dropdown to force the user to select a value in the dropdown list.

Otherwise (when not clicked) A1 displays a default value. (Already working)

I realize that "A1" could be set as the linked cell but in the layout of the workflow that is not desirable.

CodePudding user response:

There's no method that opens the combobox, but you can use the SelectionChange event on the worksheet with the combobox to first activate the combobox and then send the "Alt-Down" keys to open it.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("A1")) Is Nothing Then
    ActiveSheet.ComboBox11.Activate
    SendKeys "%{DOWN}"
End If

End Sub

This code needs to go into the relevant Sheet object in the project explorer, not a generic code module.

  • Related