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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
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:
Upvote 0
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.
 
Upvote 0
I would use the control toolbox to create any objects. From what I understand, they're way more versatile.

So, activex.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,072
Latest member
DW Draft

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