?
Solved

Excel 2007 Pivot drop downs filters retain historical data

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

777 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