Solved

Excel 2007 Pivot drop downs filters retain historical data

Posted on 2011-02-27
4
399 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
ID: 34994038
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
ID: 34994075
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)
ID: 34994233
Nope. This is a known problem with pivot caches.

Kevin
0
 

Author Comment

by:Golfer219
ID: 34994328
Awesome - thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

830 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