fiberboysa
Board Regular
- Joined
- Apr 25, 2012
- Messages
- 106
- Office Version
- 365
- Platform
- Windows
Hi Allz,
I had help from theBardd to filter multiple Pivots having different sources with one click on a Slicer in this thread. But can any one please help to adjust the following code to link it with a cell instead of a slicer?
I had help from theBardd to filter multiple Pivots having different sources with one click on a Slicer in this thread. But can any one please help to adjust the following code to link it with a cell instead of a slicer?
Code:
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)Dim Slicer As SlicerItem
Dim pvt As PivotTable
Dim pvtItem As PivotItem
Dim values As Variant
Dim nextrow As Long
Dim i As Long, ii As Long
On Error GoTo wsptu_exit
Application.EnableEvents = False
For i = 1 To Target.Slicers.Count
nextrow = 1
ReDim values(1 To nextrow)
For Each Slicer In Target.Slicers(i).SlicerCache.VisibleSlicerItems
ReDim Preserve values(1 To nextrow)
values(nextrow) = Slicer.Name
nextrow = nextrow + 1
Next Slicer
For Each pvt In Me.PivotTables
With pvt.PivotFields("SP")
.PivotItems(values(LBound(values))).Visible = True
For Each pvtItem In .PivotItems
pvtItem.Visible = Not IsError(Application.Match(pvtItem.Value, values, 0))
Next pvtItem
End With
Next pvt
Next i
wsptu_exit:
Application.EnableEvents = True
End Sub