Checking to see if any values selected in Slicer

Eric Shreve

I have some slicers on a workbook. For some of the slicers I would like to check to see if anything in that slicer is selected, and, if so, go do some stuff elsewhere in the workbook. I'm using Excel on Mac. Below is what I've tried. It give me an error of "Invalid procedure call or argument" on the "For Each" line. Any ideas on how to do this? Where I have MsgBox is where I will be putting my code for doing stuff elsewhere in the workbook.

Sub Check_Other_Slicers()
Dim si As SlicerItem

For Each si In ActiveWorkbook.SlicerCaches("District").SlicerItems

    If si.Selected = True Then
        MsgBox "x"
    End If
Next si
End Sub••••ˇˇˇˇ
Aditya

Use the following:

Sub subCheckSlicerSelection()

    Dim intCnt As Integer
    
    With ThisWorkbook.SlicerCaches("Slicer_Test")
        
        'Looping through the slicer items
        For intCnt = 1 To .SlicerItems.Count
            
            'Check if the slicer item is selected
            If .SlicerItems(intCnt).Selected Then
                
                'Show the selected value
                MsgBox .SlicerItems(intCnt).Caption
                
            End If
        
        'Next slicer item
        Next intCnt
    
    End With

End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Get value of selected values in power bi slicer

Checking to see if a checkbox is selected jquery

I am checking to see if any values in column C match with values from column B

jQuery see if any or no checkboxes are selected

Checking to see if DropDownList selected index has a value

How do we Pass the multiple selected values of a Slicer inside DAX?

Checking if any values in object are not null

Checking to see if cell values are integers, if not then adding message

Checking 2 arrays to see if they have the same values?

Checking a Pair Series values to see if they are in a List

Checking if all values are selected for a column in DAX

Checking to see if any character in a command line argument is not a '1' or a '0' in C

Checking a String (sentence space separated) to see if it contains any of the chars in an array

Pivot slicer not coordinating with selected filters

Checking to see if two corresponding values exist in same column

Checking to see if atleast one item has been selected in a checkbox list using javascript

Power Pivot Max Value Selected In Slicer

smart slicer to filter out already selected value

python function does not return any values when checking for anagram

Checking multiple columns have any of multiple values in a Table value parameter

Checking if a value is different from any in a given list of values

Checking to see if rsync was successful

Checking to see if an array is jagged

Python: See for which of the values in a list the "if any"-statement was true

I need to check a JavaScript array to see if there are any duplicate values.

How do I select rows that contain any of the selected values in any of the selected columns? MySQL

Checking if any value from a comma-separated list is selected in a multi-value parameter (in SQL dataset)

Checking if selected text is a link or not

Checking for selected dropdowns on load?