title: Autofilter Criteria with Array
body: <p>I have been looking to find a solution and cant find anything online that fully explains what is going on. I looked at some other posts but they all seem to fall a bit short. </p>
  
  <p>When I run this bit of code it works perfectly (as it was recorded).</p>
  
  <pre><code>ActiveSheet.Range("$A$1:$AL$1002").AutoFilter Field:=17, Criteria1:=Array( _
      "73578", "78759", "78765"), Operator:=xlFilterValues
  </code></pre>
  
  <p>But then when I try to make it more robust it fails. I want to change the Criteria1 argument to an already stored array.</p>
  
  <p>I am trying to get the following to work.</p>
  
  <pre><code>ActiveSheet.Range("$A$1:$AL$1002").AutoFilter Field:=17, _
      Criteria1:=Array(StoredArray.Values), Operator:=xlFilterValues
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/gshQ8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gshQ8.jpg" alt="Array values"></a></p>
  
  <p>I have the array stored and I manipulate it anyway but I have yet to get anything to work. I have also tried to create a string to be exactly like the recorded macro but that does not work either. </p>
  
  <pre><code>Dim StoredArrayString as Variant
  StoredArrayString = "73578"", ""78759"", ""78765"
  ActiveSheet.Range("$A$1:$AL$1002").AutoFilter Field:=17, _
          Criteria1:=StoredArrayString, Operator:=xlFilterValues
  </code></pre>
  
  <p>Thanks for the help here I have spent lots of time on MSDN trying to research this issue but can't find a solution.</p>