• 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.

Shows the values within the cells of a selected Slice items

OK, thanks, but how do it based VBA ?
I try it, but return only last value.
Code:
Sub Tryed()
Dim cache As Excel.SlicerCache
Set cache = ActiveWorkbook.SlicerCaches("MySlicevalue")
Dim sItem As Excel.SlicerItem
For Each sItem In cache.SlicerItems
    Range("J1").Value = sItem.Name
Next sItem
End Sub
 
Hi ,

See if this works.
Code:
Sub TryOnceMore()
    Dim i As Integer
    Dim sItem As Excel.SlicerItem
    Dim cache As Excel.SlicerCache
    Set cache = ActiveWorkbook.SlicerCaches("MySlicevalue")

    i = 0
    For Each sItem In cache.SlicerItems
        Range("J1").Offset(i).Value = sItem.Name
        i = i + 1
    Next sItem
End Sub
Narayan
 
Back
Top