Combo Boxes

xlhappy

New Member
Joined
Nov 14, 2005
Messages
18
I have two Combo boxes. Based on the selection in Combo1, the list of available choices in Combo2 changes. Once a selection is made in Combo2, should the user change their mind and go back to Combo1 to make a different selection, the original Combo2 selection is still visible in the Combo2 box. I'd like to clear it when the user makes a new selection in Combo1. I've tired to do a cbo1. Value = "" and cbo.1.Text = " ", but neither seems to work. Any idea how to clear a previous value in a Combo box ?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hmmmm . . . nope, that didn't work. Plus, I don't see ListIndex in the ComboBox properties list?
 
Upvote 0
You'll see a ListIndex property if they are on a userform. You won't if they're on a worksheet. But even if the comboboxes are on a worksheet, you can still hit the ListIndex property programatically and set it to -1.
 
Upvote 0
This is the code I put in per your suggestion:

ActiveSheet.Shapes("ComboBox2").Select
Selection.ListIndex = -1

and it errors out.
 
Upvote 0
I wouldn't use the Shapes collection to access the control. If you put the code straight in the worksheet's code module as an event handler for Combobox1's change event then when typing code into the ws's code module, if you use the keyword ME then Intellisense will list any activeX controls for you when you hit the period after ME ; the following code works just fine for me.
Code:
Private Sub ComboBox1_Change()
    Me.ComboBox2.ListIndex = -1
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

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