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 can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

xlhappy

New Member
Joined
Nov 14, 2005
Messages
18
Hmmmm . . . nope, that didn't work. Plus, I don't see ListIndex in the ComboBox properties list?
 

xlhappy

New Member
Joined
Nov 14, 2005
Messages
18

ADVERTISEMENT

ActiveX.
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
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.
 

xlhappy

New Member
Joined
Nov 14, 2005
Messages
18

ADVERTISEMENT

This is the code I put in per your suggestion:

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

and it errors out.
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,022
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,994
Messages
5,834,775
Members
430,321
Latest member
yemisimi11

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
Top