VBA Pivot Table Update Run Time Error

DoodlesMama

New Member
Joined
Aug 26, 2012
Messages
14
Hello,
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()-7
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 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

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

Sheets("Aging Calls").Select

'OLDER THAN ONE DAY
ActiveSheet.PivotTables("DBD4_Calls_Over_1Day").PivotFields("CONTACT DATE").CurrentPage = "(All)"
ActiveSheet.PivotTables("DBD4_Calls_Over_1Day").PivotFields("CONTACT DATE").PivotItems(OneDay).Visible = False

'OLDER THAN ONE WEEK
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?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top