title: Unselecting Items in a Pivot Table with an IF THEN
body: <p>I am trying to remove some fields from a Pivot Table.  The Table changes but the list of items I am trying to remove stay the same.</p>
  
  <p>It works if I just use the deselect code like this:</p>
  
  <pre><code>Set pf =ActiveSheet.PivotTables("PivotTable1").PivotFields("ServiceName")
  pf.PivotItems("Disk").Visible = False
  pf.PivotItems("SNMP").Visible = False
  pf.PivotItems("POP").Visible = False..... and so on for about 140 Items
  </code></pre>
  
  <p>My problem comes when I have a Pivot table that does not contain the PivotItem.  Run time error: "Unable to get the PivotItems property of the PivotField class</p>
  
  <p>So I thought I would us a simple IF THEN:</p>
  
  <pre><code>If pf = ("POP") Then pf.PivotItems("POP").Visible = False
  </code></pre>
  
  <p>But it doesn't work.  It doesn't do anything, no errors, no changes to the field.  It just blinks and its done.</p>
  
  <p>What am I missing?</p>