title: Filtering row labels in pivot table using vba
body: <p>I have searched a lot of forums but still haven't found the answer for this: </p>
  
  <p>I am trying to filter my row label which varies from 1 to 10, in order to only show me 5 and 10.</p>
  
  <p>I wrote the following code, but it produces error 1004 "Unable to get the PivotFields property of the PivotTable class".</p>
  
  <pre><code>ActiveWorkbook.Sheets("SideCalculations-KPIs").Activate
  With ActiveSheet.PivotTables("PivotTable1").PivotFields("ToStateId")
      .ClearAllFilters
      .PivotItems("5").Visible = True
      .PivotItems("10").Visible = True
  End With
  </code></pre>
  
  <p>thanks in advance</p>