View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Populate Combo Box With Filtered List

Private Sub UserForm_Initialize()
Dim rng As Range
cbo2.RowSource = ""
cbo2.Clear
cbo2.ColumnCount = 3
For Each rng In Range("Database").Rows
If rng.EntireRow.Hidden = False Then
cbo2.AddItem rng.Cells(1, 1).Value
cbo2.List(cbo2.ListCount - 1, 1) = rng.Cells(1, 2)
cbo2.List(cbo2.ListCount - 1, 2) = rng.Cells(1, 3)
End If
Next rng
End Sub

as an example.

--
Regards,
Tom Ogilvy




"Kinne" wrote in message
om...
Thank you Tom !
This works fine to add the filtered items to the a single column combo
box. But I need to fill the cbo with 3 columns (ID, foreign ID,
value). The ID (first column) will be used to filter the next cbo, but
I need to display a "human understandable" value in the cbo. I thought
about using "cbo.list" ... but I'm stuck. More help for me ??

Kinne


Dim rng As Range
For Each rng In

Worksheets(WorksheetFiltered).Range(RangeFiltered) .Rows
If rng.EntireRow.Hidden = False Then
' magic code here
End If
Next rng
<<

Kinne