🧩 Excel PivotTable Issue: Old Items Still Show in Filter After Deletion | 樞紐分析表問題:刪除後的舊項目仍顯示於篩選中

Have you ever deleted outdated data from your PivotTable source, only to find that the old values still appear in the filter dropdowns? This happens because Excel caches old items by default — even if they’re no longer present in the data source.

你是否曾經刪除過 PivotTable 的來源資料,但發現舊的數值仍然出現在篩選選單中?這是因為 Excel 預設會保留舊資料的快取,即使這些資料已不在來源中。

✅ Solution 1: Fix It Manually via PivotTable Options

✅ 解法一:透過樞紐分析表選項手動修正

  • Click anywhere inside the PivotTable.
  • Go to the PivotTable Analyze tab (or Options in older Excel versions).
  • Click the Options dropdown → choose PivotTable Options.
  • Go to the Data tab.
  • Set “Number of items to retain per field” to None.
  • Click OK and then Refresh the PivotTable.
  • 點擊任意樞紐分析表內部位置。
  • 切換到 樞紐分析表分析 標籤(舊版 Excel 為 選項)。
  • 點擊 選項 下拉選單 → 選擇 樞紐分析表選項
  • 切換至 資料 分頁。
  • 每個欄位保留的項目數 設為
  • 確定 並重新 更新 樞紐分析表。

✅ Solution 2: Clear Cached Items with VBA

✅ 解法二:使用 VBA 清除快取的舊項目

If you want a faster or automated way to clear old filter items in all PivotTables across your workbook, here’s a VBA method that works beautifully.

如果你希望快速或自動清除整本活頁簿中所有樞紐分析表的舊篩選項目,可以使用以下這段 VBA 程式碼,非常實用。

Sub ClearPivotCaches()
    Dim pc As PivotCache
    For Each pc In ThisWorkbook.PivotCaches
        pc.MissingItemsLimit = xlMissingItemsNone
    Next pc
    ThisWorkbook.RefreshAll
End Sub

💡 To run this code:

💡 執行這段程式碼的方法如下:

  • Press Alt + F11 to open the VBA editor.
  • Click InsertModule.
  • Paste the code above.
  • Press F5 to run it.
  • Close the VBA editor.
  • 按下 Alt + F11 開啟 VBA 編輯器。
  • 點選 插入模組
  • 貼上上述程式碼。
  • F5 執行。
  • 關閉 VBA 編輯器。

This will clear all outdated items from your PivotTable filters and refresh them automatically.

這樣會自動清除所有樞紐分析表中的舊篩選項目,並重新整理。

🛡️ Tip: For future PivotTables, remember to set the “Number of items to retain per field” to “None” when you first create them to avoid this issue.

🛡️ 提示:未來建立新的樞紐分析表時,記得一開始就將「每個欄位保留的項目數」設為「無」,以避免此問題再次發生。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *