title: Filter pivot table (connected to an external source) with range of random items
body: <p>I have a list of random items that I want to filter in an <code>Excel pivot table</code>. The pivot table is connected to an external data source. Is there any way I can filter my entire list in the pivot table without adding one item at a time to the filter?</p>
  
  <p>I've tried below code in VBA, which works on a local data source, but not when it's external.</p>
  
  <p>"56607016", "84000110", "8A20371" are some examples of items from my list.</p>
  
  <p>If there is a better solution than VBA here, please tell me.</p>
  
  <pre><code>
  Sub FilterPivotItems()
  
  Dim PT          As PivotTable
  Dim PTItm       As PivotItem
  Dim FiterArr()  As Variant
  
  ' use an array to select the items in the pivot filter you want to keep visible
  FiterArr = Array("56607016", "84000110", "8A20371")
  
  ' set the Pivot Table
  Set PT = ActiveSheet.PivotTables("PivotTable2")
  
  ' loop through all Pivot Items in "Product number" Pivot field
  For Each PTItm In PT.PivotFields("[Released products].[Product number].[Product number]").PivotItems
      If Not IsError(Application.Match(PTItm.Caption, FiterArr, 0)) Then ' check if current item is not in the filter array
          PTItm.Visible = True
      Else
          PTItm.Visible = False
      End If
  Next PTItm
  
  End Sub
  </code></pre>
  
  <p>The <strong>error message</strong> I get when running:</p>
  
  <blockquote>
    <p>"Run-time error '1004': Unable to get the _NewEnum property of the PivotItems class"</p>
  </blockquote>