The code you so kindly provided worked perfectly. Thank you again.
Here's what I ended up doing with it. (I wanted the combobox to have multiple columns, as the index number would not mean much to the user; and I wanted to filter the rows further (to exclude rows marked "D" for delete). I am posting it with my annotations for the benefit of others.
Dim rng As Range
'set lCriterion
With Sheets("Sheet1")
Set rng = .Range("C2:C" & .Cells(Rows.Count, 3).End(xlUp).Row)
'where C and 3 represent the index column (we'll compare values in this
' column to lCriterion)
'if you were to choose multiple columns, the first column would serve as
' index (so don't bother)
End With
For Each ce In rng
'where ce is an undeclared variable
If ce.Value = lCriterion Then
'where lCriterion is your criterion
If ce.Offset(0, -2) <> "D" Then
'and here's an additional condition: exclude rows that have "D" in column 1 (i.e.,
' column C minus 2)
ComboBox1.AddItem ce.Offset(0, -1).Value
'Adds the value in column B (i.e., C minus 1) to the ComboBox1
ComboBox1.List(ComboBox1.ListCount - 1, 1) = ce.Offset(0, 0)
'Adds the value in column C (ce itself) to the same line of
' ComboBox1 (ListCount -1, x) in the next column (ListCount x , 1)
ComboBox1.List(ComboBox1.ListCount - 1, 2) = ce.Offset(0, 1)
'Adds the value in column D (ce offset by 1) to the same line of
' ComboBox1 (ListCount -1, x) in the next column (ListCount x , 2)
ComboBox1.List(ComboBox1.ListCount - 1, 3) = ce.Offset(0, 2)
'And so on so that the user can see the information in 7 columns before
' choosing the row
ComboBox1.List(ComboBox1.ListCount - 1, 4) = ce.Offset(0, 3)
ComboBox1.List(ComboBox1.ListCount - 1, 5) = ce.Offset(0, 4)
ComboBox1.List(ComboBox1.ListCount - 1, 6) = ce.Offset(0, 5)
' ComboBox1.List(ComboBox1.ListCount - 1, 7) = ce.Row
'Include the line above if you want ComboBox1 to include the row number
' in Sheet1 that the line represents
End If
End If
Next ce
Bookmarks