SlicerCache.VisibleSlicerItems vs Sliceritem

Iron Contributor

I would like to know what is the difference between "SlicerCache.VisibleSlicerItems Array" & "SlicerItems.Selected"

 

I have a pivot table using a table and another pivot table directly from a query. When I use VBA to automatically select some items from the slicer both these pivot tables are showing a different code. What is the difference?

 

With the pivot table from a table, I can easily deselect a few items by settings ".SlicerItems("Item1").Selected = False", but the same is not working with the query table.

2 Replies
VisibleSlicerItemsArray are the items you see on the slicer. SlicerItems.Selected are the ones that are currently selected on the slicer.

"slicer. SlicerItems.Selected" is not just for the items that are selected, it also works the other way around. If it's value is set to true, it means the item is selected and if it is false, it means the item is deselected.

 

And "slicer. SlicerItems.Selected" can be used for chosen items(all the items of the slicer does not have to be specified). But for "VisibleSlicerItemsArray" all the items of the slicer need to be verified.

So the issue in my case is when I use "slicer. SlicerItems.Selected", I can specify 2 items that I want to deselect and set their value to false and it works perfectly fine. But when "VisibleSlicerItemsArray" is used, we need to specify all the items that need to be selected. The items on my slicer are dynamic. So there no specific list that I can input in the array.

 

For Example:

If is use

.ClearManualFilter
.SlicerItems("Item1").Selected = False
.SlicerItems("Item2").Selected = False

 

it works the way I need it to by deselecting just item1 and item2 and selected everything else. I cannot do the same using VisibleSlicerItemsArray.