Hello,
I'm trying to get my slicers name to appear on cell "D1", and the name should change when i click on different slicer option. Basically when i click onto Sales on the slicer, the name sales should appear on cell D1, and when i click onto Cost, the name cost should appear on Cell D1, and so on. Also, there is no pivot table or table involved here. I just need slicer name to appear on a cell. Here is the code:
Sub Slicer_test()
Dim cache As Excel.SlicerCache
Set cache = ActiveWorkbook.SlicerCaches("Slicer_Banner")
Dim sItem As Excel.SlicerItem
For Each sItem In cache.SlicerItems
If sItem.Selected = "HBC" Then Range("D1") = "Sales"
ElseIf sItem.Selected = "L&T" Then Range("D1") = "Cost"
ElseIf sItem.Selected = "SAKS" Then Range("D1") = "Profit"
End If
End Sub
I'm trying to get my slicers name to appear on cell "D1", and the name should change when i click on different slicer option. Basically when i click onto Sales on the slicer, the name sales should appear on cell D1, and when i click onto Cost, the name cost should appear on Cell D1, and so on. Also, there is no pivot table or table involved here. I just need slicer name to appear on a cell. Here is the code:
Sub Slicer_test()
Dim cache As Excel.SlicerCache
Set cache = ActiveWorkbook.SlicerCaches("Slicer_Banner")
Dim sItem As Excel.SlicerItem
For Each sItem In cache.SlicerItems
If sItem.Selected = "HBC" Then Range("D1") = "Sales"
ElseIf sItem.Selected = "L&T" Then Range("D1") = "Cost"
ElseIf sItem.Selected = "SAKS" Then Range("D1") = "Profit"
End If
End Sub