VBA - msoControlComboBox

Big_Belly_Bob

New Member
Joined
Feb 9, 2006
Messages
27
Hey all,

I'm trying to make a Command bar (toolbar) for excell with a combo box in it (dropdown). I have my toolbar, and my combo box with options, and the Subs that I want it to run however I'm not sure how to tell excel which Sub to use when each option is selected?

I'm using this Code for adding the Combo box

Code:
Set TstCombo = myBar.Controls.Add(Type:=msoControlComboBox)

With TstCombo
    .BeginGroup = True
    .AddItem "Option One"
    .AddItem "Option Two"
    .Style = msoComboNormal
    .Width = 100
    .OnAction = "Selector_Sub"
    
End With

My idea was to use Onaction to go to another sub (called Selector_Sub) which would then say If TstCombo = "Option One" then .... or something along those lines, although something in the code to create the Combo box that decides which Sub to use would be easier

Hope someone can help, my knowlage of VB is quite rudimentary as I've just picked it up as I go along.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,214,591
Messages
6,120,431
Members
448,961
Latest member
nzskater

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