Guinaba
Board Regular
- Joined
- Sep 19, 2018
- Messages
- 233
- Office Version
- 2016
- Platform
- Windows
Hi guys,
Trying to create a function that reads the value from the selected slicer's button in a cell. I am using data dictionary for that, but not sure where the error is, when I change the selection in the slicer the function doesn't get updated.
Trying to create a function that reads the value from the selected slicer's button in a cell. I am using data dictionary for that, but not sure where the error is, when I change the selection in the slicer the function doesn't get updated.
VBA Code:
Function SlicerReader() As Dictionary
Dim sc As SlicerCache
Dim si As SlicerItem
Dim dctItem As Object
Set dctItem = CreateObject("Scripting.Dictionary")
Set sc = ActiveWorkbook.SlicerCaches("Slicer_ItemID_Desc")
For Each si In sc.SlicerItems
If si.Selected Then
dctItem.Add si.Value, si.Value
ActiveWorkbook.Sheets("Total_TPRP").Range("L5").Value = dctItem.Items
End If
Next
Set dctItem = Nothing
End Function