I m using this code to deselect all slicers report connections in my file. How can I adjust the code that would select (instead of deselect) the slicer connections? Thanks in advance!
VBA Code:
Sub DisconnectAllSlicers()
Dim SlicersDict As Variant
Set SlicersDict = CreateObject("Scripting.Dictionary")
Dim sl As SlicerCache, slpt As PivotTable, SlItem As Variant
'create a dictionary with slicers and connected pivot tables
For Each sl In ThisWorkbook.SlicerCaches
SlicersDict.Add Key:=sl.Name, Item:=sl.PivotTables
Next
'take each slicer
For Each SlItem In SlicersDict.Keys
'remove pt connections for this slicer
For Each slpt In SlicersDict(SlItem) 'for each pivot table controlled by this slicer,
slpt.SaveData = True
ThisWorkbook.SlicerCaches(SlItem).PivotTables.RemovePivotTable (slpt)
Next slpt
Next SlItem
Set SlicersDict = Nothing
End Sub