title: Filtering pivot table with vba
body: <p>I have a chart that picks the info from a pivot table that I have with daily data.
  I am trying to create activeX buttons so it can filter the data which is as ROW LABEL, to see how my data behaved in the last week and in the last month</p>
  
  <p>So, what I have until now and it is not working is:</p>
  
  <p>Private Sub weekbtn1_Click()
      Dim i As Integer</p>
  
  <pre><code>If weekbtn1 = True Then
  i = 0
  Do Until Datavalue(date) - i = 42005
  With ActiveSheet.PivotTables("Pivotcompsprice").PivotFields("Date")
      .PivotItems DateValue(Date) - i.Visible = False
      i = i + 1
  End With    
  Loop
  
  i = 0
  Do Until i = 7
  With ActiveSheet.PivotTables("Pivotcompsprice").PivotFields("Date")
      .PivotItems Datevalue(date) - i.Visible = True
  End With
  Loop
  Else
  End If
  </code></pre>
  
  <p>End Sub</p>
  
  <p>I put this 42005 because it is the last date that I have the data which is 1/1/2015...I was thinking that it was possible to filter all the data as "false" and then Making True what I want, but it doesn't work!</p>
  
  <p>Can someone help me?</p>