Dynamic listing of ComboBox?

zabiullakhan

Active Member
Joined
Aug 30, 2010
Messages
310
I have this code to populate ComboBox2 with refrence to ComboBox1, however this ComboBox2 is not geting updated. please help

Code:
Private Sub ComboBox1_Change()
    If ActiveSheet.ComboBox1.Value = "animals" Then
        ActiveSheet.ComboBox2.ListFillRange = Range("Reference!B2:B7")      
    ElseIf ActiveSheet.ComboBox1.Value = "flowers" Then
        ActiveSheet.ComboBox2.ListFillRange = Range("Reference!B8:B14") 
    ElseIf ActiveSheet.ComboBox1.Value = "colors" Then
       ActiveSheet.ComboBox2.ListFillRange = Range("Reference!A14:A15")  
    End If
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

wut

Banned
Joined
Dec 13, 2010
Messages
229
I think I don't understand what you're asking.
 
Last edited:

wut

Banned
Joined
Dec 13, 2010
Messages
229
That's because I was trying to set the listfilledrange as a range... same as you were.

Get rid of the "Range()"; just, "Reference!AX:BX"

eg:

Code:
Private Sub ComboBox1_Change()<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
    If ActiveSheet.ComboBox1.Value = "animals" Then<o:p></o:p>
<o:p> </o:p>
        ActiveSheet.ComboBox2.ListFillRange = [COLOR=red]"Reference!A14:A15"<o:p></o:p>[/COLOR]
<o:p> </o:p>
    ElseIf ActiveSheet.ComboBox1.Value = "flowers" Then<o:p></o:p>
<o:p> </o:p>
        ActiveSheet.ComboBox2.ListFillRange = [COLOR=red]"Reference!A14:A15"<o:p></o:p>[/COLOR]
<o:p> </o:p>
    ElseIf ActiveSheet.ComboBox1.Value = "colors" Then<o:p></o:p>
<o:p> </o:p>
       ActiveSheet.ComboBox2.ListFillRange = [COLOR=red]"Reference!A14:A15"<o:p></o:p>[/COLOR]
<o:p> </o:p>
    End If<o:p></o:p>
<o:p> </o:p>
End Sub
 
Last edited:

zabiullakhan

Active Member
Joined
Aug 30, 2010
Messages
310

ADVERTISEMENT

I get this error at line 3
"Object dosent support this property or method"

please help
 

wut

Banned
Joined
Dec 13, 2010
Messages
229
I tried the code out and it works just fine. Take it step by step. Start with this. Does this block work for you?

Code:
Private Sub ComboBox1_Change()
 
    If ActiveSheet.ComboBox1.Value = "animals" Then
 
        ActiveSheet.ComboBox2.ListFillRange = "Sheet1!A14:A15"

    End If
 
End Sub

Start with a brand new workbook;

Put two comboboxes on it;

Fill "A14" and "A15" with text;

Enter "design" mode and double-click on the first combo-box;

Paste the code above into the object module;

Go back to your new worksheet and type "animals" into the first combo-box;

Come back here if it doesn't work.
 

wut

Banned
Joined
Dec 13, 2010
Messages
229
I would use the control toolbox to create any objects. From what I understand, they're way more versatile.

So, activex.
 
Last edited:
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,164,530
Messages
5,837,895
Members
430,520
Latest member
VenkateshRajaganesan

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