tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,937
- Office Version
- 365
- 2019
- Platform
- Windows
I have a custom combobox created in my workbook on the ribbon.
This is the xml code:
This is my VBA code:
If I make a change to the combobox, say I choose "Apples", cell A1 on the worksheet changes to "Apples". If I change the value in the combobox to "Pears", cell A1 changes to "Pears". This is what I want.
In addition though, I want to occur, ie if I change the value in cell A1 from "Apples" to "Oranges", I want the combobox to update with the value "Oranges".
How can this be done?
I tried all sorts of Invalidating the combobox but for some reason, it doesn't update.
Thanks
This is the xml code:
Code:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="False">
<tabs>
<tab id="CustomTab" label="My Tab">
<group id="Group1" label="MyGroup">
<comboBox id="MyCombo"
label="Attributes"
sizeString="AAAAAAAAAAAAAAAAAA"
onChange="ComboBox_OnChange">
<item id="First" label="Apples" />
<item id="Second" label="Oranges" />
<item id="Third" label="Pears" />
</comboBox>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
This is my VBA code:
Code:
'Callback for MyCombo onChange
Sub ComboBox_OnChange(control As IRibbonControl, text As String)
Cells(1, 1) = text
End Sub
If I make a change to the combobox, say I choose "Apples", cell A1 on the worksheet changes to "Apples". If I change the value in the combobox to "Pears", cell A1 changes to "Pears". This is what I want.
In addition though, I want to occur, ie if I change the value in cell A1 from "Apples" to "Oranges", I want the combobox to update with the value "Oranges".
How can this be done?
I tried all sorts of Invalidating the combobox but for some reason, it doesn't update.
Thanks