title: Run-time error 1004 when trying to select OLAP pivotfield array element
body: <p>I'm having trouble looping through the items in my OLAP pivot field. I have an array which contains the names/items I want the filter to loop through, but I cannot get the pivot field to select an array element (I want only one selected at a time)</p>
  
  <p>There are many questions out there with similar problems out there, like <a href="http://www.vbaexpress.com/forum/showthread.php?56582-VBA-amp-OLAP-Pivot-Code-to-set-report-filter-pvt-field-with-items-from-another-pvt-tabl" rel="nofollow noreferrer">this</a>
   and <a href="https://www.mrexcel.com/forum/excel-questions/621374-filter-olap-pivot-table-based-named-range-another-worksheet.html" rel="nofollow noreferrer">this</a>, and I have tried to incorporate the coding to my code. However I can't seem to get it to work for me</p>
  
  <p>This is my code at the moment. I have tried using currentpage rather than visibleitemlist, and instead of element just use i or industryarray(i).</p>
  
  <pre><code>Sub Test()
  
  Dim IndustryArray() As Variant
  Dim element As Variant
  
  Dim Industry As Range
  Dim Data As Variant
  
  Dim ptITS As PivotTable
  Dim pfITS As PivotField
  Dim ppfITS As PivotField
  
  Set ptITS = Worksheets("Industry Time Series").PivotTables("PivotTable1")
  Set pfITS = ptITS.PivotFields("[All Industries Combined].[Industry Details].[Industry Details]")
  Set ppfITS = ptITS.PageFields("[All Industries Combined].[Industry Details].[Industry Details]")
  
  Set Industry = Worksheets("Industry List").Range("A2:A211")
  ReDim IndustryArray(0 To Industry.Cells.Count + 1)
  
  For i = 0 To Industry.Cells.Count + 1
      IndustryArray(i) = "[ All Industries Combined].[Industry Details].&amp;[" &amp; Industry.Cells(i + 1).Value &amp; "]"
  Next i
  
  For Each element In IndustryArray
      pfITS.ClearAllFilters
      pfITS.VisibleItemsList = element &lt;-- error (for different variations as well)
  Next element
  
  End Sub
  
  </code></pre>
  
  <p>I want the filter to select each item of the array, then clear filter and move to the next item. Just get errors at the identified line.</p>
  
  <p>Any help would be appreciated!</p>