After you change the source data for a pivot table, the old items might still appear in the drop downs. The instructions below will help you clear those items.
The data in the pivot table source may change, and items that were previously in the source are no longer included. For example, a company resturctured, and went down from 3 regions -- East, Central and West -- to only 2 regions -- East and West.
Even after you refresh the pivot table, the name of the old region might continue to appear in the drop down lists, along with the new names. In the list below, the Central region still appears in the list.
This pivot table tutorial shows how you can clear the old items either manually or programmatically.
NOTE: There is also a Clear Old Items feature in my PivotPower Premium add-in, along with many other time-saving pivot table tools.
This short video shows how to change a setting in a pivot table, so old items do not appear in the drop down lists. The written instructions are below the video.
To prevent old items from being retained in an Excel 2010 or 2007 pivot table, you can change an option setting:
Instead of changing a setting, you can manually clear the old items from the drop down lists:
In Excel 2002, and later versions, you can programmatically change the pivot table properties, to prevent missing items from appearing, or clear items that have appeared.
Sub DeleteMissingItems2002All() 'prevents unused items in non-OLAP PivotTables 'pivot table tutorial by contextures.com Dim pt As PivotTable Dim ws As Worksheet Dim pc As PivotCache 'change the settings For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables pt.PivotCache.MissingItemsLimit = xlMissingItemsNone Next pt Next ws 'refresh all the pivot caches For Each pc In ActiveWorkbook.PivotCaches On Error Resume Next pc.Refresh Next pc End Sub
Sub DeleteOldItemsWB() 'pivot table tutorial by contextures.com 'gets rid of unused items in PivotTable ' based on MSKB (202232) Dim ws As Worksheet Dim pt As PivotTable Dim pf As PivotField Dim pi As PivotItem On Error Resume Next For Each ws In ActiveWorkbook.Worksheets For Each pt In ws.PivotTables pt.RefreshTable pt.ManualUpdate = True For Each pf In pt.VisibleFields If pf.Name <> "Data" Then For Each pi In pf.PivotItems If pi.RecordCount = 0 And _ Not pi.IsCalculated Then pi.Delete End If Next pi End If Next pf pt.ManualUpdate = False 'pt.RefreshTable 'optional - might hang Excel 'if 2 or more pivot tables on one sheet Next pt Next ws End Sub
Download the zipped sample file for this tutorial.
Last updated: September 22, 2016 7:20 PM