tatersmom
10-25-2008, 06:50 AM
If this combobox were on a userform, I'd have no problem with how to do this. But I need to have two comboboxes embedded on a worksheet. One will load a list of items from a range, not a problem. I have a list on a separate worksheet that I pull the data from.
The other, however, I am lost with. I need to load it from one of two different lists, depending on what item is picked from the first combobox list.
I tried writing a subroutine something like this, assuming the first combobox is linked to cell A1 and the two different lists to choose from are in cells F20:F23 and G20:G23.
sub comboBox1_Change()
if activesheet.range("A1").value = 1 then
comboBox2.list = range("F20:F23")
elseif activesheet.range("A1").value = 2 then
comboBox2.list = range("G20:G23")
end if
end sub
I get an error saying "Object Required" and highlighting one of the lins that starts with "comboBox2.list". I'm guessing it needs it's object (duh!). Is the object the sheet its on because I know it's not on a userform. When I change those two lines to read "ActiveSheet.comboBox2.list = ..." I get the error "Object doesn't support this property or method".
If the worksheet isn't the object, what is the object?
Also, the forms were built from the forms control menu, not the activex menu.
Thanks.
The other, however, I am lost with. I need to load it from one of two different lists, depending on what item is picked from the first combobox list.
I tried writing a subroutine something like this, assuming the first combobox is linked to cell A1 and the two different lists to choose from are in cells F20:F23 and G20:G23.
sub comboBox1_Change()
if activesheet.range("A1").value = 1 then
comboBox2.list = range("F20:F23")
elseif activesheet.range("A1").value = 2 then
comboBox2.list = range("G20:G23")
end if
end sub
I get an error saying "Object Required" and highlighting one of the lins that starts with "comboBox2.list". I'm guessing it needs it's object (duh!). Is the object the sheet its on because I know it's not on a userform. When I change those two lines to read "ActiveSheet.comboBox2.list = ..." I get the error "Object doesn't support this property or method".
If the worksheet isn't the object, what is the object?
Also, the forms were built from the forms control menu, not the activex menu.
Thanks.