title: VBA pivot filter on variable date
body: <p>I'm really struggling with coding pivot tables in VBA. I just want to filter on a variable date. With 1 pivot it works fine, with the other pivot - which uses the same data - I always get the same error messages: </p>
  
  <blockquote>
    <p>unable to get the PivotTables property of the Worksheet class</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>str_Date_To_Show = Format(Date, "m/d/yyyy")
  
  'Pivot1
  
  Sheets("Pivot").PivotTables("PivotTable1").PivotFields("Date").ClearAllFilters
  Sheets("Pivot").PivotTables("PivotTable1").PivotFields("Date"). _
          EnableMultiplePageItems = False
  Sheets("Pivot").PivotTables("PivotTable1").PivotFields("Date").CurrentPage = str_Date_To_Show
  
  'Pivot3
  Sheets("Pivot3").PivotTables("PivotTable3").PivotFields("Date").ClearAllFilters
  Sheets("Pivot3").PivotTables("PivotTable3").PivotFields("Date"). _
          EnableMultiplePageItems = False
  Sheets("Pivot3").PivotTables("PivotTable3").PivotFields("Date").CurrentPage = str_Date_To_Show
  </code></pre>
  
  <p>I also tried this for Pivot3. It works when I hard-code the date in VBA but then I don't manage to make <code>2017-09-01</code> a variable.</p>
  
  <pre><code>ActiveSheet.PivotTables("PivotTable3").PivotFields("[Range].[Date].[Date]"). _
      VisibleItemsList = Array("[Range].[Date].&amp;[2017-09-01T00:00:00]")
  </code></pre>