Sub topic 11
Connecting One Control to Several PivotTables
This chapter assumes you can insert a slicer or a timeline and make selections in it. It also assumes you know what a PivotTable cache is, at least roughly. A report with several PivotTables, such as sales by region, sales by product, and a monthly trend, needs one slicer or timeline that filters all of them together. Excel calls this a report connection.
How a control is tied to PivotTables
When you insert a slicer, Excel creates two objects:
- The slicer, which is the visible box of buttons on the sheet.
- The slicer cache, a hidden workbook object that stores the current selection. Its default name is
Slicer_plus the field name, for exampleSlicer_Region.
PivotTables do not listen to the slicer directly. They are attached to the slicer cache. A slicer filters every PivotTable attached to its cache, and a connection is the link between a PivotTable and that cache. Timelines work the same way, with a timeline cache that holds the selected date range.
Inserting a control from one PivotTable connects it to that PivotTable only. Every other PivotTable has to be connected deliberately.
Connecting a slicer
- Click the slicer to select it.
- On the Slicer tab of the ribbon, choose Report Connections. You can also right-click the slicer and choose Report Connections.
- In the dialog, tick the box next to each PivotTable that the slicer should filter.
- Click OK.
Click a button in the slicer. Every ticked PivotTable now filters to that selection. Clearing the slicer with the Clear Filter button in its top corner clears the filter on all connected PivotTables at once.
The dialog lists PivotTables by their names, and Excel assigns defaults such as PivotTable1 and PivotTable7. In a report with more than two PivotTables you cannot tell which is which. Before you open the dialog, select each PivotTable and rename it on the PivotTable Analyze tab in the PivotTable Name box. Use names like ptSalesByProduct and ptSalesByMonth.
Connecting a timeline
The steps are the same, but the command is on a different tab:
- Click the timeline.
- On the Timeline tab, choose Report Connections.
- Tick the PivotTables to filter and click OK.
A timeline connects only to PivotTables that use the same date field from the same source data. The connected PivotTables do not have to display that date field. They only have to include it in their data source. If you select March to May 2026 in the timeline, every connected PivotTable shows only data from those months.
The shared cache rule
A PivotTable appears in the Report Connections dialog only if it uses the same pivot cache as the PivotTable the control was created from. The pivot cache is the in-memory copy of the source data that Excel keeps for PivotTables. Two PivotTables built on the same cache can be filtered by one control, because the control filters the cache's data. Two PivotTables on different caches have no shared data to filter.
This is why a PivotTable that you expected to see is sometimes missing from the dialog. The usual causes are:
| Situation | Shares a cache? |
|---|---|
| PivotTable copied and pasted from another PivotTable | Yes |
| PivotTable created with **Insert > PivotTable** from the same range or Table, in the same workbook | Often yes, but not guaranteed |
| PivotTable created from a different range, even with identical data | No |
| PivotTable created from an external connection that was refreshed or recreated separately | Not necessarily |
| PivotTable in another workbook | No |
| PivotTables built from the Data Model | Yes, they share the model |
The reason for the "often yes" row is that Excel decides whether to reuse a cache when you create the PivotTable. If you want certainty, create the second PivotTable by copying the first. Copy it with Ctrl+C and Ctrl+V on another sheet, then rearrange its fields. The copy always shares the cache, so it always appears in Report Connections.
What happens in the connected PivotTables
A connected PivotTable does not need the slicer's field in any area. A Region slicer can filter a PivotTable that shows only Product in Rows and Sales in Values. The slicer filters the underlying cache data, and the PivotTable recalculates from the filtered data.
Keep these edge cases in mind:
- Report filter on the same field. If a connected PivotTable also has Region in its Filters area, the two filters apply together. The PivotTable shows only data that passes both. If the report filter hides an item that the slicer selects, you may see an empty PivotTable. Remove duplicate filters from connected PivotTables to avoid this.
- Different slicers on the same field. Each slicer has its own cache. Two Region slicers connected to the same PivotTable filter it together, and selections in one do not update the other. Create one slicer per field and connect it to every PivotTable that needs it.
- Disconnecting. Clearing a tick in Report Connections removes the PivotTable from the filter. It keeps whatever filtering state it had and then stops responding to the control.
- Several controls. A PivotTable can be connected to many slicers and timelines at once. Their filters combine, so each added control narrows the data further.
- Refreshing. Connections survive Refresh All. They break if you delete or recreate a PivotTable, which creates a new object that has no connections yet.
Doing it with VBA
The VBA object model reflects the same structure. SlicerCaches is a collection on the workbook, and each slicer cache has a PivotTables collection that is the list of ticked boxes in the dialog.
This macro adds the second PivotTable on the active sheet to the Slicer_Region cache. It does what ticking the box in Report Connections does. The PivotTable must share the same pivot cache, and the cache name must match the one in your workbook.
Sub ConnectSlicerToSecondPivot()
Dim sc As SlicerCache
Set sc = ActiveWorkbook.SlicerCaches("Slicer_Region")
sc.PivotTables.AddPivotTable ActiveSheet.PivotTables(2)
End SubIf the PivotTable uses a different cache, AddPivotTable raises a run-time error. That matches the dialog hiding the PivotTable.
To check which PivotTables each control filters, list the connections:
Sub ListConnections()
Dim sc As SlicerCache
Dim pt As PivotTable
For Each sc In ActiveWorkbook.SlicerCaches
Debug.Print sc.Name
For Each pt In sc.PivotTables
Debug.Print " " & pt.Name & " on " & pt.Parent.Name
Next pt
Next sc
End SubThe output appears in the Immediate window (Ctrl+G in the VBA editor). Timeline caches appear in the same collection as slicer caches. Chapter 15 covers the object model in more detail.
Checking your connections
After you set up connections, test them before you trust the report:
- Click one button in the slicer and check that every connected PivotTable changes.
- If one does not change, open Report Connections and confirm its box is ticked.
- If it is not listed, check whether it shares the pivot cache. The easiest test is to recreate it by copying a PivotTable that is already connected.
- Click Clear Filter and confirm that all PivotTables return to their full totals.
Exercise
You have a Region slicer connected to PivotTable A. You create PivotTable B by selecting a different range that contains the same data, and B does not appear in the Report Connections dialog for the slicer. Why is that, and how would you fix it?
Show answer
B uses a different pivot cache because it was built from a different range, and a slicer can only connect to PivotTables that share its pivot cache. To fix it, delete B and recreate it by copying A and pasting the copy, then rearrange the fields. Alternatively, build both PivotTables from the same Excel Table or the Data Model. Then tick B in Report Connections.
Exercise
A Region slicer is connected to three PivotTables. One of them also has Region in its Filters area, set to "East", and the slicer selection is "West". What do you expect to see in that PivotTable, and what is the cleanest fix?
Show answer
Both filters apply, so no row can satisfy both East and West and the PivotTable is probably empty. The cleanest fix is to remove Region from the PivotTable's Filters area and let the slicer control it.