Solved

Excel 2007 Pivot drop downs filters retain historical data

Posted on 2011-02-27
4
394 Views
Last Modified: 2012-05-11
We recently migrated over to Excel 2007 and I'm noticing something strange with a few pivot tables I have in the background of a few reporting templates.

When I clear out old data and drop in new data, the drop downs in the pivot table that allow you to filter, not only have the new values but also the old values.  For example, my pivot is set to show all values which returns 10 rows of data, however the drop down shows close to 100 different values to chose from (note - everything is selected).

Is there an option in 2007 to ensure historical values are not retained?

Thanks!
0
Comment
Question by:Golfer219
  • 2
  • 2
4 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
Comment Utility
When a PivotTable's source data is modified such that certain values used in page, rows, or columns are removed the values will remain in the PivotTable menus even after a refresh. Use one or more of the following routines to remove the unused values from the menus.

[Begin Code Segment]

Public Sub RefreshWorkbookPivotTableMenus()

' Refresh menus in all workbook PivotTables.

   Dim TargetWorksheet As Worksheet

   On Error Resume Next
   For Each TargetWorksheet In ActiveWorkbook.Worksheets
      RefreshWorksheetPivotTableMenus TargetWorksheet
   Next

End Sub

Public Sub RefreshWorksheetPivotTableMenus(ByRef TargetWorksheet As Worksheet)

' Refresh menus in all PivotTables in a specific worksheet.

   Dim TargetPivotTable As PivotTable

   On Error Resume Next
   For Each TargetPivotTable In TargetWorksheet.PivotTables
      RefreshPivotTableMenus TargetPivotTable
   Next

End Sub

Public Sub RefreshPivotTableMenus(ByRef TargetPivotTable As PivotTable)

' Refresh menus in a specific PivotTable.

   Dim TargetPivotField As PivotField
   Dim TargetPivotItem As PivotItem

   On Error Resume Next
   TargetPivotTable.RefreshTable
   For Each TargetPivotField In TargetPivotTable.VisibleFields
      For Each TargetPivotItem In TargetPivotField.PivotItems
         If TargetPivotItem.RecordCount = 0 And Not TargetPivotItem.IsCalculated Then
            TargetPivotItem.Delete
         End If
      Next
   Next

End Sub

[End Code Segment]

Kevin
0
 

Author Comment

by:Golfer219
Comment Utility
Thanks Kevin - appreciate the fast response!

Are you aware of any non-VB way of doing this?  If not, that's OK.  Thanks!
0
 
LVL 81

Expert Comment

by:zorvek (Kevin Jones)
Comment Utility
Nope. This is a known problem with pivot caches.

Kevin
0
 

Author Comment

by:Golfer219
Comment Utility
Awesome - thanks!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now