I am creating the report that is updated daily and need assistance with dates in Pivot Tables within the report.

I have one sheet within the report that is for service call aging and contains two pivot tables on it for one and seven days. Our reporting system runs one day behind, so the formula needs to actually be for 2 and 8 days.

One for any calls over 1 day. =Today()-2
One for any calls over 7 days. =Today()-8

Since these are within a Pivot Table, I have tried several variations to ensure the Pivot Table reflects all the data minus 1 day and 7 days, but keep getting an error. The error and VBA code are reflected below.

  1. ERROR: Run-time error '1004: Unable to get the PivotItems property of the PivotField class.
  2. VBA:

Sub Aging_Calls()

Dim OneDay As String
Dim SevenDay As String

OneDay = Format(Date - 2, "mm/dd/yyyy")
SevenDay = Format(Date - 8, "mm/dd/yyyy")

Sheets("Aging Calls").Select

ActiveSheet.PivotTables("DBD4_Calls_Over_1Day").PivotFields("CONTACT DATE").CurrentPage = "(All)"
ActiveSheet.PivotTables("DBD4_Calls_Over_1Day").PivotFields("CONTACT DATE").PivotItems(OneDay).Visible = False

ActiveSheet.PivotTables("DBD4_Calls_Over_1Week").PivotFields("CONTACT DATE").CurrentPage = "(All)"
ActiveSheet.PivotTables("DBD4_Calls_Over_1Week").PivotFields("CONTACT DATE").PivotItems(SevenDay).Visible = False

End Sub

Can any of you please help me?