Hi All, have trawled the net with no complete answer so am once again turning to the good people of MrExcel.
I have a userform which contains 2 list boxes. ListBox1 uses the below code to cycle through a range and removes duplicates (works fine). I need listbox2 to populate itself based on the selection of listbox1.
There are 2 ranges one inside the other laid out like this:
Team1 Job1
Team1 Job2 etc.
Team2 Job1
Team2 Job2 etc
Team3 etc.
One range is just the one column (Teams Column) where I get the team names using listbox1 code.
The second range is both columns (Teams and Jobs Column) and i would like Listbox2 to populate with any entries in Column 2 that have the selected team in column 1.
Listbox1 code: Function CREATE_TEAM_LIST()
Dim v, e
With Sheets("Lists").Range("team_list")
v = .Value
End With
With CreateObject("scripting.dictionary")
.comparemode = 1
For Each e In v
If Not .exists(e) Then .Add e, Nothing
Next
If .Count Then Me.cmbReqTeam.List = Application.Transpose(.keys)
End With
End Function
Hope this made sense.
Thanks
Mike
I have a userform which contains 2 list boxes. ListBox1 uses the below code to cycle through a range and removes duplicates (works fine). I need listbox2 to populate itself based on the selection of listbox1.
There are 2 ranges one inside the other laid out like this:
Team1 Job1
Team1 Job2 etc.
Team2 Job1
Team2 Job2 etc
Team3 etc.
One range is just the one column (Teams Column) where I get the team names using listbox1 code.
The second range is both columns (Teams and Jobs Column) and i would like Listbox2 to populate with any entries in Column 2 that have the selected team in column 1.
Listbox1 code: Function CREATE_TEAM_LIST()
Dim v, e
With Sheets("Lists").Range("team_list")
v = .Value
End With
With CreateObject("scripting.dictionary")
.comparemode = 1
For Each e In v
If Not .exists(e) Then .Add e, Nothing
Next
If .Count Then Me.cmbReqTeam.List = Application.Transpose(.keys)
End With
End Function
Hope this made sense.
Thanks
Mike
Last edited: