PDA

View Full Version : [SOLVED:] Trying to Shorten/Simplify some Code to Make it Easier to Apply To Other Workbooks



Jim Clayton
06-12-2018, 01:40 PM
Hello everyone. Trying to find some help. Theattached workbook has slicers. A contributor from another forum came up with a solution that allows me to hide the irrelevant ones when not in use by treating them as shapes. It works greatfor THIS workbook, but is difficult for me to apply to OTHER workbooks that haveadditional slicers due to my limited VBA knowledge. Wondering if there's a way to simplify it. Thanks everyone for your help. Let me know if anything further is needed.

Bob Phillips
06-12-2018, 02:46 PM
Maybe this


Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
Dim shp As Shape
Dim shpName As String

With Me

For Each shp In .Shapes

shpName = shp.Name
If shp.Type = msoSlicer Then _
shp.Visible = Not .Parent.SlicerCaches("Slicer_" & shp.Name).SlicerItems.Item(1).Value = "N/A"
Next shp
End With
End Sub