Dear all,

I have a requirement to add Slicer and modify Slicer settings.

I use the following code to create "Age" Slicer for the field "Age" referring to the Pivot table " PivotTable1 " whose Name is "Age_Slicer" and Caption is " Age Values "

ActiveWorkbook.SlicerCaches.Add2(ActiveSheet.PivotTables("PivotTable1"), "Age").Slicers.Add ActiveSheet, ,"Age_Slicer", "Age Values", 198.5, 561, 144, 198.75
However, I need to modify the Slicer to have the Age values to be displayed over 5 columns. I recorded my action and see the following auto-generated code:

ActiveWorkbook.SlicerCaches("Slicer_Age").Slicers("Age").NumberOfColumns = 5
I understand that I need to get control of the Slicer setting ' Name to use in formulas ' to be able to achieve my goal. Currently, i'm unable to do the same.

Request your help to be able to define the Slicer setting ' Name to use in formulas ' through VBA

This is very important as I have to create multiple Slicers for various Pivot Tables and "Age" field is the most common Slicer that I would need.

Thanks,
Vinod Krishna