Example file now attached!
I have a workbook with several sheets including one named "Pivot" and one named "Timesheet". The sheet named Timesheet contains the source data for the pivot on the Pivot sheet.
I have a dropdown on the Pivot sheet which changes the data in the Timesheet depending on the selection made. I want the pivot table to refresh automatically when I make my selections in the dropdown list.
I am using the following code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Timesheet").PivotTables("Timesheet_Pivot").PivotCache.Refresh
End Sub
But it isn't working. When I make selections in the dropdown list, nothing updates in the pivot. If I go into the Timesheet source data and manually change some data, I get the following message:
Run-time error '1004':
Unable to get the PivotTables property of the Worksheet class
How can I fix this problem? I named the table of data on the Timesheet sheet "Timesheet", and I named the Pivot table "Timesheet_Pivot".
Bookmarks