I have a pivot table with a list of activities and progress. I created several graph under each other, what I would like to achive is to use my slicer buttons as a hyperlink aswell. Once I select an activity on the slicer, it should adress me to the right graph. e.g. If I click to activity1 on the slicer, it should also select a range where my graph is, so I can see it. (A40:A70)
It would help me a lot, thanks.
CodePudding user response:
I think you can use the PivotTableUpdate event and then read the slicer objects to see what was clicked.
It would look something like this
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
With Me.Parent.SlicerCaches("Slicer_Activity")
Select Case True
Case .SlicerItems("Activity1").Selected
Me.Range("A40:A70").Select
Case .SlicerItems("Activity2").Selected
Me.Range("A90:A120").Select
'as many other case statement as you need
End Select
End With
End Sub
CodePudding user response:
Thank you @DickKusleika I have tried but it does't work for me, maybe I do something wrong
I was playing with this one, but the problem is now where ever I click on the slicer it brings me to the first selection
Sub Discipline_Click()
With ActiveWorkbook.SlicerCaches(1)
If .SlicerItems(1).Selected = True Then
Range("A13:A20").Select
ElseIf .SlicerItems(5).Selected = True Then
Range("B13:B20").Select
End If
End With
End Sub