Answered by:
Macro assigned to Slicer does't work

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 Integercounter = 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 iIf counter = 0 Then
Sheets("RDWay Specific").Select
Range("A5").Select
ActiveCell.FormulaR1C1 = "None"
ActiveWorkbook.SlicerCaches("Slicer_Specific_Solution").ClearManualFilter
Sheets("All Estimates").Select
End IfEnd Sub
Wednesday, November 12, 2014 6:44 PM
Answers
-
May I ask what the use case is for this? Are the slicers referring to the same field in the Power Pivot model?
- Proposed as answer by Ed Price - MSFTMicrosoft employee Tuesday, January 6, 2015 6:49 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, February 4, 2015 7:35 PM
Monday, January 5, 2015 5:58 PM
All replies
-
San, is this still an issue?
Thanks!
Ed Price, Azure & Power BI Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)
Answer an interesting question? Create a wiki article about it!Wednesday, December 31, 2014 2:45 AM -
Hallo
Yes this is still an issue
Monday, January 5, 2015 5:22 PM -
May I ask what the use case is for this? Are the slicers referring to the same field in the Power Pivot model?
- Proposed as answer by Ed Price - MSFTMicrosoft employee Tuesday, January 6, 2015 6:49 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, February 4, 2015 7:35 PM
Monday, January 5, 2015 5:58 PM