Results 1 to 5 of 5

Select date range in multiple Pivots

Threaded View

BartDeHertogh Select date range in multiple... 01-20-2010, 05:28 AM
DonkeyOte Re: Select date range in... 01-20-2010, 06:03 AM
BartDeHertogh Re: Select date range in... 01-20-2010, 06:18 AM
Gaura215 Re: Select date range in... 06-27-2012, 03:08 AM
arlu1201 Re: Select date range in... 06-27-2012, 03:55 AM
  1. #1
    Registered User
    Join Date
    01-11-2010
    Location
    Belgium
    MS-Off Ver
    Excel 2003
    Posts
    23

    Select date range in multiple Pivots

    Hi,
    I'd like to select the start date & end date for multiple Pivots (on one sheet).
    Expl. if I put in a date in the "Start Date" cell : 01/01/2010 and another date in the "End Date" cell : 15/01/2010. Then all the pivots on the sheet should only show the date between 01/01 and 15/01/2010.
    The dates in the pivots are under column "Date".
    I have a code but it only selects 1 pivot and it doesn't refresh the pivots when you change the dates selection...
    Could you help me ?

    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("Data").Range("StartDate").Value
    dEnd = Sheets("Data").Range("EndDate").Value
    
    Set pt = ActiveSheet.PivotTables(2)
    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 pi.Value < dStart Or 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 BartDeHertogh; 01-20-2010 at 06:22 AM.

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