I have created a "Summary" tab using an Excel Pivot Table.
The Pivot Table shows the sums of selected values in various categories stored in a "Details" tab.
The Details tab contains...
Select? Type Price
Y Shoe $1.25
N Shoe $1.50
Y Boot $2.00
N Clog $3.00
Y Shoe $0.50
The Summary tab shows a Pivot Table like this...
Select? Y
Row Labels Sum of Price
Boot $2.00
Shoe $1.75
Whenever something is changed in the Details tab, and someone switches to the Summary tab, I want the Pivot Table to auto update to match the new data.
This is easy if just the values change (using the first code snippet below), but if the Y and N change, the filtering does not update. Anything that has changed from N to Y is not shown until the filtering is manually updated.
This is what I have so far...
The code to auto-update a Pivot Table is e.g. ...
Private Sub Worksheet_Activate()
Sheets("Summary").PivotTables("PivotTable1").RefreshTable
End Sub
The code to auto-refresh an Excel auto-filter column in a table (that's not a Pivot Table) is e.g. ...
Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveWorkbook.Worksheets("Details").ListObjects("Table1")
.AutoFilter.ApplyFilter
End With
End Sub
...but I cannot figure out how to apply AutoFilter.ApplyFilter to a Pivot Table. Any ideas? Or Equivalent?
The nearest thing I found to touch the Pivot Table filter is this code which will turn the part I want to update yellow...
Worksheets("Details").PivotTables("PivotTable1") _
.PageRange.Interior.Color = vbYellow
...but I don't want to turn it yellow :-) , I want to re-apply the filter to the modified data so I see what I should see, rather than the wrong values and missing rows.
Many thanks.