Solved

Excel 2007 Pivot drop downs filters retain historical data

Posted on 2011-02-27
4
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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 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.

740 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