title: Dynamic VBA macro to hide all pivot table values
body: <p>Looking for a dynamic and quick way to hide all pivot table values. As of now, I have the code below, but this only works as long as there aren't any new values (Example: if account "333" was added to the data, the script would break). Any suggestions?</p>
  
  <pre><code>Sub Hide_Accounts()
     With ActiveSheet.PivotTables("PivotTable2").PivotFields("Account")
         .PivotItems("000").Visible = False
         .PivotItems("111").Visible = False
         .PivotItems("222").Visible = False
         .PivotItems("(blank)").Visible = False
     End With
  End Sub
  </code></pre>