All,
I've tried this code I found, but all it ever returns is the last error message that the slice name doesn't exist. Here is the code:
Any help would be appreciated!
I've tried this code I found, but all it ever returns is the last error message that the slice name doesn't exist. Here is the code:
Code:
Public Function GetSelectedSlicerItems(SNme As String) As String
Dim oSCache As SlicerCache
Dim oSItem As SlicerItem
Dim lCnt As Long
On Error Resume Next
Application.Volatile
Set oSCache = ThisWorkbook.SlicerCaches("SNme")
If Not oSCache Is Nothing Then
For Each oSItem In oSCache.VisibleSlicerItems
If oSItem.Selected Then
GetSelectedSlicerItems = GetSelectedSlicerItems & oSItem.Name & ", "
lCt = lCt + 1
End If
Next
If Len(GetSelectedSlicerItems) > 0 Then
If lCt = oSCache.VisibleSlicerItems.Count Then
GetSelectedSlicerItems = "All Items"
Else
GetSelectedSlicerItems = Left(GetSelectedSlicerItems, Len(GetSelectedSlicerItems) - 2)
End If
Else
GetSelectedSlicerItems = "No items selected"
End If
Else
GetSelectedSlicerItems = "No slicer with name " & S_Name & " was found"
End If
End Function
Any help would be appreciated!