Solved

Excel 2007 Pivot Table Filter Based On Dynamic Cell

Posted on 2011-03-07
2
914 Views
Last Modified: 2012-05-11
Hello Experts - Please see attached file.  I'd like to know if there is a way to based multiple pivot table filter selections on a specific cell.  Based on the attached sample file, if someone was to chose a different month in cell M2 on the first tab, all of the filters in the 3 pivot tables would change to that new month.

Thanks!!!
EE-Sample-File.xlsm
0
Comment
Question by:Escanaba
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
Comment Utility
Right-click the worksheet tab, choose View Code then paste this in:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim pt As PivotTable
   Dim pf As PivotField
   On Error GoTo err_handle

   With Application
      .ScreenUpdating = False
      .EnableEvents = False
   End With
   If Not Intersect(Target, Me.Range("M2")) Is Nothing Then
      For Each pt In Me.PivotTables
         pt.ManualUpdate = True
         Set pf = pt.RowFields(1)
         pf.ClearAllFilters
         pf.PivotFilters.Add Type:=xlCaptionEquals, Value1:=Range("M2").Value
         pt.ManualUpdate = False
      Next pt
   End If
clean_up:
   With Application
      .EnableEvents = True
      .ScreenUpdating = True
   End With
   Exit Sub

err_handle:
   MsgBox Err.Description
   Resume clean_up
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:Escanaba
Comment Utility
As always, thank you for your quick and accurate response.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

771 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

11 Experts available now in Live!

Get 1:1 Help Now