Forum Discussion
icorte
May 23, 2019Copper Contributor
can you add a Macro Button based on Slicers?
I have a document with 4 connected slicers. Basically a road/process map on what text to log in salesforce. I want to assign a macro where someone can click a "button" and text will populate in ...
Berndvbatanker
May 24, 2019Iron Contributor
and here it is... i'm new here and i don't know how to attach files...
Sub SelectSelectedSlicer()
Dim sC As SlicerCache
Dim objItem As Object
Dim strSelection As String
Set sC = ActiveWorkbook.SlicerCaches("Slicer_Case_Type1")
With sC
For Each objItem In .SlicerItems
If objItem.Selected = True Then
strSelection = strSelection & objItem.Caption & ";"
End If
Next objItem
End With
Set sC = ActiveWorkbook.SlicerCaches("Slicer_Outcome?1")
With sC
For Each objItem In .SlicerItems
If objItem.Selected = True Then
strSelection = strSelection & objItem.Caption & ";"
End If
Next objItem
End With
Set sC = ActiveWorkbook.SlicerCaches("Slicer_Detailed_Reason1")
With sC
For Each objItem In .SlicerItems
If objItem.Selected = True Then
strSelection = strSelection & objItem.Caption & ";"
End If
Next objItem
End With
Set sC = ActiveWorkbook.SlicerCaches("Slicer_Detailed_Reasons_Description1")
With sC
For Each objItem In .SlicerItems
If objItem.Selected = True Then
strSelection = strSelection & objItem.Caption & ";"
End If
Next objItem
Sheet1.Range("U7").Value = strSelection
End With
End Sub