Thanks for your examples. In my case, I have a form FrmFilter on which
I have comboboxes and 1 listbox called ListBox1. The listbox is
automatically populated with a specific range on a sheet called
"PARMS". So far so good. The user should be able to select 1, 2 or n
selections in this listbox and pass the values to a autofilter. So
like you wrote, what I need is something like:
With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
strCrit1 = "=" & ListBox1.List(i, 0)
End If
Next i
End With
But how can I make this code work to loop through all possible values
(which can vary, depending of number of items on sheet PARMS) and make
sure that each strCritn has it's own unique value.
For example I have a defined range ITEMS that consitst of "A", "B" and
"C".
The user selects in the listbox1 on the userform option "A" and option
"C". Those 2 items need to go to strCrit1 and strCrit2 and then I need
something like this: Selection.AutoFilter Field:=1,
Criteria1:=strCrit1, Operator:=xlOr, Criteria2:=strCrit2
But the next time the user selects let say 4 items. Then the
autofilter should be something like Selection.AutoFilter Field:=1,
Criteria1:=strCrit1, Operator:=xlOr, Criteria2:=strCrit2,
Operator:=xlOr, Criteria3:=strCrit8, Operator:=xlOr,
Criteria4:=strCrit10
Thank you for your help.
Mark