Filtering rows of Combo Boxes

jjrythem
07-11-2010, 04:39 PM
I have a fairly large worksheet that has different parts and their corresponding specifications, for example..

ID | Length | Type | Color
23 --- 3' ----- G --- Blue
12 --- 3' ----- L --- Green
04 --- 3' ----- G --- Green
22 --- 2' ----- P --- Red
67 --- 1' ----- G --- Blue

I am creating a user form to be able to easily select the right ID, by narrowing down the list using Color, Type, or Length. I'm using 4 Combo Boxes where if the user selects Green it should list only 2 Entries for the Type combo box (L and G) and only 3' for the type box. I think I explained what I am trying to do simply enough. I can't figure out the filtering part I have the 4 combo boxes populated with the correct rows using named ranges but I'm not sure how or even if I can filter the way I am trying to with named ranges. Any help would be great, thanks!

Josh Hazel
07-11-2010, 06:23 PM
Instead of using the built in RowSource, use the .Additem method, google for how to use .additem using VBA
Then
Use a loop, like For ... Next and within this loop check for condition if the .range("A" & i) = ComboBox1 then .additem
You would of course need to remove/ or .clear the comboboxes as well before running each loop
Hope that gives you a start

jjrythem
07-12-2010, 03:55 PM
Hey thanks a lot I think I am on the right track, I believe I have what I need but it just doesn't seem to work...


MsgBox(ws.Range("G" & i).Value) 'Returns a number.
MsgBox(Me.cboLampsFixtures.Value) 'Returns a number.
If ws.Range("G" & i).Value = Me.cboLampsFixtures.Value Then
MsgBox ("score.")
cboFixtureDesc.AddItem ws.Range("B" & i).Value
End If


Even though in the message boxes preceding the if statement it will say 1, 1 the If statement is never true so the Item is never added to the other list.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum