For..next.. help to fill listbox

J

jasonsweeney

THis is what I need:

In a user form, I need to fill 4 different listboxs with specific item
that fill specific criteria....

1) I have a list of 930 items in Column A
2) In columns B,C,D,E,F I have other various items germane to the ite
in Column A (company division, product line, weight, size, price, etc.
There are only FOUR product lines common to all divisions. (lets cal
them "LINE1", "LINE2", "LINE3", LINE4 and say that these names ar
entered in column C)

I have a userform that asks the user to select the COMPANY DIVISIO
from a combo box. I need four combo boxes to be populated with al
products from the product lines for that division.

So I am thinking I need to do some sort of a for...next loop to chec
the criteria of the cells in the worksheet to see if they should b
added to the listbox....problem is I am somewhat of a novice in VBA an
am not so good with the for..next loops...

What I need is a code that kind of does something like this:
__________________________________________________
'For Product Line 1 List Box: '' FIRST list box
' for each cell in range (x)
' If combobox1.value = Cell in Column B in Sheet2 value AND cell offse
(0,1) = LINE1 then additem to listbox1
' next

'For Product Line 2 List Box: '' SECOND list box
' for each cell in range (x)
' If combobox1.value = Cell in Column B in Sheet2 value AND cell offse
(0,1) = LINE2 then additem to listbox2
' next

Etc.
_____________________________________
Can someone help me please with the correct code for such a addite
technique
 
B

Bob Phillips

Something like

For i = 1 To Cells(Rows.Count,"A").End(xlUp).Row
If Cells(i,"B").Value = ComboBox1.Value
Listbox1.AddItem Cells(i,"C").Value
Listbox2.AddItem Cells(i,"D").Value
Listbox3.AddItem Cells(i,"E").Value
Listbox4.AddItem Cells(i,"F").Value
End If
Next i
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top