Updating custom combobox by changing value on worksheet

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,937
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a custom combobox created in my workbook on the ribbon.

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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
EDIT SORTED:

Code:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"
onLoad="Initialise"> 
  <ribbon startFromScratch="false"> 
    <tabs> 
      <tab id="CustomTab" label="MyTab"> 
        <group id="Group1" label="MyGroup"> 
          <comboBox id="abc" 
                    label="Attributes" 
                    sizeString="AAAAAAAAAAAAAAAAAA" 
                    onChange="ComboBox_OnChange" 
                        getText="Module1.Combo_GetText">
            <item id="First" label="Apples" /> 
            <item id="Second" label="Oranges" /> 
            <item id="Third" label="Pears" /> 
          </comboBox>  
        </group> 
      </tab> 
    </tabs> 
  </ribbon> 
</customUI>

Ths was omitted:

Code:
onLoad="Initialise">
 
Upvote 0

Forum statistics

Threads
1,226,516
Messages
6,191,499
Members
453,659
Latest member
thomji1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top