locked
Macro assigned to Slicer does't work RRS feed

  • Question

  • I have 2 slicers: Slicer_Solution and Slicer_Specific_Solution

    I wrote a macro to select in Slicer_Specific solution the same button as as selected in the slicer Slicer_Solution.

    The code works, when running the Macro "stand_alone". (run macro)

    but when I Assign the macro to Slicer_Solution, it doesn't work anymore. The slicer seems blocked, I cannot click on other buttoms of the slicer after running the macro

    herby the code:

    Sub Slicer_Selection()

    Dim Selection As Boolean
       
    Selection = False
       
    Application.ScreenUpdating = False


    ActiveWorkbook.SlicerCaches("Slicer_Specific_Solution").ClearManualFilter


    Dim i As Integer
    Dim j As Integer
    Dim counter As Integer

    counter = 0

    For i = 1 To ActiveWorkbook.SlicerCaches("Slicer_Solution").SlicerItems.Count
        For j = 1 To ActiveWorkbook.SlicerCaches("Slicer_Specific_Solution").SlicerItems.Count
            If ActiveWorkbook.SlicerCaches("Slicer_Specific_Solution").SlicerItems(j).Value = ActiveWorkbook.SlicerCaches("Slicer_Solution").SlicerItems(i).Value Then
                If ActiveWorkbook.SlicerCaches("Slicer_Solution").SlicerItems(i).Selected Then
                    counter = counter + 1
                    If counter = 1 Then
                        Sheets("RDWay Specific").Select
                        Range("A5").Select
                        ActiveCell.FormulaR1C1 = ActiveWorkbook.SlicerCaches("Slicer_Specific_Solution").SlicerItems(j).Value
                        Sheets("All Estimates").Select
                    Else
                        Sheets("RDWay Specific").Select
                        Range("A5").Select
                        ActiveCell.FormulaR1C1 = "Many"
                        Sheets("All Estimates").Select
                    End If
                Else
                    ActiveWorkbook.SlicerCaches("Slicer_Specific_Solution").SlicerItems(j).Selected = False
                End If
            End If
        Next j
    Next i

    If counter = 0 Then
        Sheets("RDWay Specific").Select
        Range("A5").Select
        ActiveCell.FormulaR1C1 = "None"
        ActiveWorkbook.SlicerCaches("Slicer_Specific_Solution").ClearManualFilter
        Sheets("All Estimates").Select
    End If

    End Sub

    Wednesday, November 12, 2014 6:44 PM

Answers

All replies