• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help with Slicer name appearing on a Cell

Sk123

New Member
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
 
Back
Top