• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

List all items in a Slicer regardless of if they are selected

kmk_qba

New Member
All the data is in a Data Model in this Workbook
I have a Table with Dates in them and the slicer is based on the date.
I want to be able to see if a range of Dates have been selected in the slicer or individual Dates have been selected.
ie (Selected March 20, 2021 to April 4, 2021 - Then I can say in a report this data is From March 20, 2021 to April 4, 2021
but if March 20, 2021 & March 25, 2021 & April 4, 2021 were selected in the Slicer I want to say in a report this data is For
March 20, 2021 & March 25, 2021 & April 4, 2021)
I wanted to read in the selected Dates in the slicer (Got the code for this) But then I want to Read all items in the Slicer items to compare.
 
Last edited:
Just figured it out. To list all items in a Selected Slicer in Data Model Slicer into a column in a spreadsheet use the following code

>>> use code - tags <<<
Code:
Sub Demo()
    Dim slc As SlicerCache
    Dim sli As SlicerItem
    Dim cnt As Integer
   
    Set slc = ThisWorkbook.SlicerCaches("Slicer_Test")
    cnt = slc.SlicerItems.Count
    For a = 1 To cnt
        Range("B" & a) = slc.SlicerItems.Item(a).Caption
    Next
End Sub
 
Last edited by a moderator:
Back
Top