Filtering a OLAP cube Pivot Table with a slicer VBA (overflow message workarounds)

drkballaerospace

New Member
Joined
Jul 18, 2017
Messages
3
Hi all,

Thanks for your help in advance!

I am trying to use a slicer to filter through my OLAP cube pivot table. When I loop through all Slicer Items I get an overflow message so I replaced .Count with .VisibleSlicerItems.Count and now I am getting an "Object doesn't support this property or method" error message. Any advice? Or maybe there is a better approach to take. My end goal is to allow a user to input two keywords and search through the "Part Description" field for entries that contain both or one of those values. This is a trial case using just one value.

My current code:
Code:
Dim sC As SlicerCache
Dim sL As SlicerCacheLevel
Dim sI As SlicerItem
Dim aArray() As Variant
Dim i As Long
Dim pdk1 As String
pdk1 = PD1.Value
'this value is coming from a userform

ActiveWorkbook.SlicerCaches.Add2(ActiveSheet.PivotTables("NEWAR"), _
        "[Part].[Part Description]").Slicers.Add ActiveSheet, _
        "[Part].[Part Description].[Part Description]", "Part Description", _
        "Part Description", 306.75, 786, 144, 198.75

Set sC = ActiveWorkbook.SlicerCaches("Slicer_Part_Description")
Set sL = sC.SlicerCacheLevels(1) 'this will start with the first item in the slicer

 With sL
           For i = 1 To .VisibleSlicerItems.Count
               'initally For i = 1 to .Count but that gave overflow message
                  If sL.SlicerItems.Item(i).Name Like "*" & pdk1 & "*" Then
                      'check if pdk1 is contained anywhere in the slicer item caption
                                      ReDim Preserve aArray(0 To i) As Variant
                                     aArray(i) = sL.SlicerItems.Item(i).Name
                                     'add that slicer item name to an array
                 End If
Next i
            
sC.VisibleSlicerItemsList = aArray 'this set the visible items
                                               '= to the array you just created
            
'ActiveSheet.Shapes("Part Description").Visible = False
            'to hide this slicer, uncomment the line above
    End With
 
Last edited by a moderator:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top