ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For..next.. help to fill listbox (https://www.excelbanter.com/excel-programming/295699-next-help-fill-listbox.html)

jasonsweeney[_69_]

For..next.. help to fill listbox
 
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

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

For..next.. help to fill listbox
 
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)

"jasonsweeney " wrote in
message ...
THis is what I need:

In a user form, I need to fill 4 different listboxs with specific items
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 item
in Column A (company division, product line, weight, size, price, etc.)
There are only FOUR product lines common to all divisions. (lets call
them "LINE1", "LINE2", "LINE3", LINE4 and say that these names are
entered in column C)

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

So I am thinking I need to do some sort of a for...next loop to check
the criteria of the cells in the worksheet to see if they should be
added to the listbox....problem is I am somewhat of a novice in VBA and
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 offset
(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 offset
(0,1) = LINE2 then additem to listbox2
' next

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


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 04:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com