+ Reply to Thread
Results 1 to 3 of 3

Filter several pivot tables by one programmed date range filter in Excel 2003

Hybrid View

olewka Filter several pivot tables... 08-08-2011, 10:50 AM
olewka Re: Filter several pivot... 08-08-2011, 11:16 AM
Mordred Re: Filter several pivot... 08-08-2011, 11:49 AM
  1. #1
    Registered User
    Join Date
    08-08-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    2

    Filter several pivot tables by one programmed date range filter in Excel 2003

    Hi all,

    Please help.
    Currently I am using programmed date range filter for pivot table in Excel 2003. I would like to make it work for several pivot tables on one spreadsheet coming from one data source. Does anyone have an idea how to make it work for several pivot tables at once?

    Here is the code I am currently using:

    Sub FilterPivotDates()
    
    Dim dStart As Date
    Dim dEnd As Date
    Dim pt As PivotTable
    Dim pf As PivotField
    Dim pi As PivotItem
    Application.ScreenUpdating = False
    On Error Resume Next
    dStart = Sheets("SalesPivot").Range("StartDate").Value
    dEnd = Sheets("SalesPivot").Range("EndDate").Value
    Set pt = ActiveSheet.PivotTables(1)
    Set pf = pt.PivotFields("Date")
    pt.ManualUpdate = True
    pf.EnableMultiplePageItems = True
    For Each pi In pf.PivotItems
      pi.Visible = True
    Next pi
    For Each pi In pf.PivotItems
       If CDate(Replace(pi.Value, ".", "/")) < dStart Or CDate(Replace(pi.Value, ".", "/")) > dEnd Then
        pi.Visible = False
      End If
    Next pi
    Application.ScreenUpdating = False
    pt.ManualUpdate = False
    Set pf = Nothing
    Set pt = Nothing
    End Sub
    Last edited by Mordred; 08-08-2011 at 11:47 AM. Reason: Used the wrong tags.

  2. #2
    Registered User
    Join Date
    08-08-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Filter several pivot tables by one programmed date range filter in Excel 2003

    here is the excel sheet with example
    Attached Files Attached Files

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Filter several pivot tables by one programmed date range filter in Excel 2003

    Hi olweka, In the future please use code tags around you code as per Rule #3 of the forum rules (located in my signature). You used PHP tags instead of code tags. I have edited your post to include code tags so no worries but like I said, in the future please use code tags for VBA code. Thank you.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1