Private Sub CommandButton1_Click()
Dim r As Long
Range("A6").Select
r = Range("A6", Range("A6").End(xlDown)).Cells.Count
For x = 0 To r
For i = 0 To CSJList.ListCount - 1
'You don't have to select it to iterate the list.
'CSJList.Selected(i) = True
If CSJList.List(i).Value <> ActiveCell.Offset(x, 0).Value Then
ActiveCell.Offset(r, 0).EntireRow.Hidden = True
End If
Next i
Next x
End Sub
You can do away with the combobox and only use the listbox. Set the MultiSelect=True, then the user can select multiple items in the listbox.
Private Sub CommandButton1_Click()
Dim r As Long
Range("A6").Select
r = Range("A6", Range("A6").End(xlDown)).Cells.Count
For x = 0 To r
For i = 0 To CSJList.ListCount - 1
If Not CSJList.Selected(i) Then
If CSJList.List(i).Value <> ActiveCell.Offset(x, 0).Value Then
ActiveCell.Offset(r, 0).EntireRow.Hidden = True
End If
End If
Next i
Next x
End Sub
Bookmarks