I am using Excel 2010 for the following:
I have ten Pivot tables on a "Dashboard" sheet. I want to create a slicer that filters all ten pivot tables. When I try to connect the pivot tables to the slicer the first one works but the second one fails with the 1004 error.
I checked to see if all ten pivot tables use the same pivot cache and they do not.
I tried setting all to use the same pivot cache but that fails with the 1004 error also.
This is the code I use to create the Slicer and connect pivot tables to it:
I use this code to make each pivot table use the same pivotcache:
I need help to determine why the 1004 error is being thrown and what I need to do to use a single Slicer to filer all ten pivot tables?
Thanks in advance for your time and help,
Marcus
I have ten Pivot tables on a "Dashboard" sheet. I want to create a slicer that filters all ten pivot tables. When I try to connect the pivot tables to the slicer the first one works but the second one fails with the 1004 error.
I checked to see if all ten pivot tables use the same pivot cache and they do not.
I tried setting all to use the same pivot cache but that fails with the 1004 error also.
This is the code I use to create the Slicer and connect pivot tables to it:
Code:
ActiveWorkbook.SlicerCaches.Add(Sheets("DashBoard").PivotTables("pta"), _
"field 1").Slicers.Add Sheets("DashBoard"), , "field 1", _
"Select field 1 " & _
"HOLD DOWN CTRL KEY TO SELECT MULTIPLE values. CLICK ON FILTER ICON TO CLEAR.", 51.12 _
, 1.44, 768, 56
ActiveWorkbook.SlicerCaches("Slicer_field_1").Slicers("field 1"). _
NumberOfColumns = 10
ActiveWorkbook.SlicerCaches("Slicer_field_1").Slicers("field 1").Style _
= "SlicerStyleDark1"
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptb"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptc"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptd"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("pte"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptf"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptg"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("pth"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptj"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptk"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptl"))
ActiveWorkbook.SlicerCaches("Slicer_field_1").PivotTables.AddPivotTable (Sheets("DashBoard") _
.PivotTables("ptm"))
I use this code to make each pivot table use the same pivotcache:
Code:
Private Sub ChangePivotCache()
'pivot table tutorial by contextures.com
'change pivot cache for all Pivot Tables in workbook
Dim pt As PivotTable
Dim wks As Worksheet
Dim i As Long
i = Sheets("Dashboard").PivotTables("pta").CacheIndex
For Each pt In Sheets("DashBoard").PivotTables
If pt.name = "pta" Then
Else
pt.CacheIndex = i
End If
Next pt
End Sub
I need help to determine why the 1004 error is being thrown and what I need to do to use a single Slicer to filer all ten pivot tables?
Thanks in advance for your time and help,
Marcus
Last edited: