Using string array as criteria in VBA autofilter
<p>I've searched other posts and found similar issues but nothing that could help me specifically. I'm trying to take an array of strings and use it as a filter criteria. It's tricky because the array is created by a function and has a variable number of elements and contents. I need the autofilter to take it and check <strong>column E</strong> for each one of its elements. </p>

<p>I've tried it two ways</p>

<p>1)</p>

<pre><code>With Sheet17

    .Range("E1").AutoFilter Field:=5, Criteria1:=Application.Transpose(arr)

End With
</code></pre>

<p>Result: Applies a filter to column E but fails to select any of the options </p>

<p>2)</p>

<pre><code>For i = 0 To counter - 1

    With Sheet17

        .Range("E1").AutoFilter Field:=5, Criteria1:=Application.Transpose(arr(i))

    End With

Next
</code></pre>

<p><strong>Note:</strong> Counter is an integer representing the number of elements in the array.</p>

<p><strong>Result:</strong> This one correctly loops through the array but only selects the last option on the filter - presumably because every time it loops back through it starts over and unchecks every other option so by the end only the most recent option remains checked.</p>