I'm making a Custom Tab for Excel with Custom UI Editor and I have two DropDown controls in it. Let's call them DropDown1 and DropDown2. My goal is that whenever I change the DropDown1 selection it automatically changes de DropDown2 selection, but I don't know how to set the "SelectedItem" in a DropDown Control.
So far I have a VBA function which is triggered every time I change the selection of DropDown1, I think that can be helpfull.
You need to add a callback function to you ribbon XML in the Custom UI Editor and then add the corresponding code to you VBA project to be called when the ribbon tab gets invalidated. The callback you need to set the selected item for the dropdown control is either
getSelectedItemIndex
orgetSelectedItemID
, depending on if you want to select the item by index or by id. Since you have not provided any code, my examle is general (and not tested):Ribbon XML:
VBA callback
EDIT:
Example where index is selected based on other droplist. In similar solutions I have set a value in the
onAction
function of one control and used it to set the selected index in another control, something like the following:Ribbon XML:
VBA callbacks