title: VBA pivot table sum/count button
body: <p>as stated in the title i'm trying to make a button  that swaps betweend the count and the sum in a particular pivot table field i could make it in two but i've troubles with the IF statement this is what i came up with : </p>
  
  <pre><code>Sub Count()
  '
  ' Macro3 Macro
  '
  
      With ActiveSheet.PivotTables("PivotTable2").PivotFields("Sum of SP/UOM")
          .Caption = "Count of SP/UOM"
          .Function = xlCount
      End With
  
  End Sub
  
  Sub Sum()
  '
  ' Sum Macro
  '
  
      With ActiveSheet.PivotTables("PivotTable2").PivotFields("Count of SP/UOM")
          .Caption = "Sum of SP/UOM"
          .Function = xlSum
      End With
  
  End Sub
  </code></pre>
  
  <p>If someone has an idea on how to make it I would be thankful !</p>