?
Solved

Excel 2007 Pivot drop downs filters retain historical data

Posted on 2011-02-27
4
Medium Priority
?
405 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 2000 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

Independent Software Vendors: 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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

809 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