[RESOLVED] USER FORM : ListBox population based on another ListBox value selection [VBA]
Hi,
User Form :
https://cdn1.imggmi.com/uploads/2019...5915c-full.jpg
Worksheet :
https://cdn1.imggmi.com/uploads/2019...0627a-full.jpg
In my User form there is listbox which consists of 3 values. Rated Current_Order set 1 , Rated Current_Order set 2 , Rated Current_Order set 3.
Based on the selection of these 3 order set , values should populate in the corresponding right side listbox , "Values for the selected attribute" .
The Values are populated from the worksheet "AttrOrderSetDefinition" .(Please refer the screenshot) .
If we select 1st orderset , values from "G3" to its end should populate in the next listbox. if we select 2nd , values from "H3" should populate and similar for the 3rd.
Someone please help me for this code.
westconn1 is my daily savior .
Re: USER FORM : ListBox population based on another ListBox value selection [VBA]
assuming that the order set are in order in the list box you can use the index of the first listbox to specify the column for the data
Code:
Private Sub ComboBox1_Click()
popnxtlist ComboBox1.ListIndex
End Sub
Sub popnxtlist(i As Integer)
dim r as range
set r = Range("g3").Offset(, i).Address
MsgBox r.address
' populate the next listbox from the data below r
note i used a combobox but a listbox would be the same
the popnxtlist can be used generically for any number of listboxes, by passing the target listbox with the listindex as a second parameter
eg if you had 4 or 5 cascading, each filled from the value selected in the previous one this procedure would save writing the code multiple times for each list box
Re: USER FORM : ListBox population based on another ListBox value selection [VBA]
@wetconn1 Working fine as usual . Thanks a lot.