ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Populate List / Combo Box (https://www.excelbanter.com/excel-discussion-misc-queries/48999-populate-list-combo-box.html)

Dave C

Populate List / Combo Box
 
I want to populate a list box with filtered values from column y based on the
value in column x matching the value in cell a1.

Column y contains a list of players.
Column x contains the team to which the player belongs
A1 will be updated by the user with the team name
The list box will then display the players who are members of the team in A1

I'd be grateful for suggestions how to acheive the filtering rather than
populating the list box with all column y values and therefore displaying
all players irrespective of their team.

Thanks in advance,

David

Jim Rech

You might do something like this:

Sub PopListbox()
Dim Cell As Range
For Each Cell In Range("X1:X20")
If Cell.Value = Range("A1").Value Then
Sheet1.ComboBox1.AddItem Cell.Offset(0, 1).Value
End If
Next
End Sub

--
Jim
"Dave C" wrote in message
...
|I want to populate a list box with filtered values from column y based on
the
| value in column x matching the value in cell a1.
|
| Column y contains a list of players.
| Column x contains the team to which the player belongs
| A1 will be updated by the user with the team name
| The list box will then display the players who are members of the team in
A1
|
| I'd be grateful for suggestions how to acheive the filtering rather than
| populating the list box with all column y values and therefore
displaying
| all players irrespective of their team.
|
| Thanks in advance,
|
| David




All times are GMT +1. The time now is 02:07 AM.

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