how to determine SlicerCaches?

storm8

Active Member
Joined
Apr 7, 2010
Messages
327
Hello,
I have a workbook with data and many sheets which contain various pivot tables for that data. After I create new pivot table, I want to add slicers to it. So far I was able to create the slicers the way I want:
Code:
ActiveWorkbook.SlicerCaches.Add(ActiveSheet.PivotTables(c_pt), sname).Slicers.Add ActiveSheet, , sxname, sname, pv, ph, sw, sh
(sname is name of the field and slicer, sxname is the name and random number (because in the workbookt there are many slicers with the same name eg month), the rest is position...)
however I would also like to modify some of its properties, such as number of columns, row height, etc
Code:
ActiveWorkbook.SlicerCaches("Slicer_month5").Slicers("month 5").NumberOfColumns = 2
For this I need to know the slicerCaches value, which I do not control when creating.

How do I do this? Also how do I connect the slicer to all pivottables on the worksheet?

thank you very much!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Something like this (I can't test because I don't have Excel 2010 here):

Code:
    Dim SC As SlicerCache
    Set SC = ActiveWorkbook.SlicerCaches.Add(ActiveSheet.PivotTables(c_pt), sname)
    With SC
        .Slicers.Add ActiveSheet, , sxname, sname, PV, ph, sw, sh
        .Slicers("month 5").NumberOfColumns = 2
    End With
 
Upvote 0
Hi Andrew, please can you assist. The following code RESETS ALL Slicers in the entire workbook...

How do I get this to run on the ActiveSheet Only please???

Sub Slicer()
Dim slcr As SlicerCache
For Each slcr In ActiveWorkbook.SlicerCaches
slcr.ClearManualFilter
Next slcr
Call Refresh
End Sub

Many thanks,
Clint
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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