title: Switch pivot table filter using VBA macro (button)
body: <p>I need help with some rather easy macro, but I can't do that. So all I want is to switch between filters - I have two possibilities, by example two colours - black and white, and I only want to have one of them in the moment (I want to add button, so it will work as switch). Here is the situation</p>
  
  <p><img src="https://i.stack.imgur.com/51Ors.jpg" alt="pivottable"></p>
  
  <p>I've tried did it with conditional, of course it doesn't work, but hope it will helps you to understand my idea. If one filter is enable, the other one is disabled (so the objects connected with that obviously too).</p>
  
  <pre><code>Sub Makro5()
  
  ActiveSheet.PivotTables("PivotTable3").PivotFields("colour"). _
      CurrentPage = "(All)"
  
  If ActiveSheet.PivotTables("PivotTable3").PivotFields("colour")
      .PivotItems("black").Visible = False
      .PivotItems("white").Visible = True
      Then ActiveSheet.PivotTables("PivotTable3").PivotFields ("colour")
      .PivotItems("black").Visible = True
      .PivotItems("white").Visible = False
      Else: ActiveSheet.PivotTables("PivotTable3").PivotFields ("colour")
      .PivotItems("black").Visible = False
      .PivotItems("white").Visible = True
  
  End Sub
  </code></pre>
  
  <p>Something is wrong with If, because it's on red and I get "Complie error: Syntax error" info</p>