Hi. I've got a data table (Table1) and a slicer. On another sheet, I have a pivot table and chart. I'd like to be able to trigger the pivot chart update when the slicer gets changed. I've tried the code below (which works as a standalone module) in a worksheet_change event, and that didn't work. From reviewing a plethora of posts, it appears that a slicer change can't trigger this event. So I tried adding a sub-total formula to cell $Z$1 on the worksheet and tried the Worksheet_SelectionChange event, and that also didn't work. I can sort of get my head around why the first one didn't work, but why wouldn't the Worksheet_SelectionChange event see the change in cell Z1? Is there any way to get this to trigger the event? Thanks for looking.
Dim wkb As Workbook
Dim wksData As Worksheet
Dim wksPT As Worksheet
Dim cCountry As String
Dim FirstVizCell As String
Dim pt As PivotTable
Dim Field As PivotField
Set wkb = ThisWorkbook
Set wksData = wkb.Sheets("OUS Complaints")
Set wksPT = wkb.Sheets("Escalation Pivot Tables & Chart")
Set pt = wksPT.PivotTables("PivotTable1")
Set Field = pt.PivotFields("Country")
If Target.Address = "$Z$1" Then
wkb.Activate
wksData.Select
With wksData
FirstVizCell = Range("D3:D" & Rows.Count).SpecialCells(xlVisible)(1).Address
cCountry = Range(FirstVizCell).Value
'This updates and refreshes the PIVOT table
With pt
Field.ClearAllFilters
Field.CurrentPage = cCountry
pt.RefreshTable
End With
End With
End If
End Sub
Bookmarks