+ Reply to Thread
Results 1 to 9 of 9

Update all pivots with column filter

  1. #1
    Registered User
    Join Date
    08-09-2011
    Location
    Utrecht
    MS-Off Ver
    Excel 2013
    Posts
    48

    Update all pivots with column filter

    Hi All,

    I am trying to update all pivots with the extra function that it updates the column filter as well. Up till now I have the following code:

    PHP Code: 
    Sub RefreshAllPivotTables()

    Dim PT As PivotTable
    Dim WS 
    As Worksheet

        
    For Each WS In ThisWorkbook.Worksheets

            
    For Each PT In WS.PivotTables
              PT
    .RefreshTable
              PT
    .ClearAllFilters
              PT
    .pivotfiels("Year Week").PivotFilters.Add Type:=xlCaptionIsBetweenValue1:="201501"Value2:="201552"
            
    Next PT

        Next WS

    End Sub 
    The problem occurs when I am Clearing all filters ("PT.Clearallfilters") and I am a bit stuck how to solve this problem.

    I would be pleased if someone has the solution for this problem.

    Thanks in advanced,

    Cheers, Jeroen

  2. #2
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Update all pivots with column filter

    Hello Jeroen,

    Would this solve the problem?
    Please Login or Register  to view this content.
    Harry.

  3. #3
    Registered User
    Join Date
    08-09-2011
    Location
    Utrecht
    MS-Off Ver
    Excel 2013
    Posts
    48

    Re: Update all pivots with column filter

    Hi Harry,

    The problem still occurs when the code hits "PT.clearallfilters". Do you have any suggestions how to solve the problem?

    Cheers, Jeroen

  4. #4
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Update all pivots with column filter

    Maybe it helps if you upload the file Jeroen.

  5. #5
    Registered User
    Join Date
    08-09-2011
    Location
    Utrecht
    MS-Off Ver
    Excel 2013
    Posts
    48

    Re: Update all pivots with column filter

    Attached you can find the file.

    Thanks!
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Update all pivots with column filter

    There's no number "201521" longer in the source, but stil in the pivot.

    See attached file how to handle.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-09-2011
    Location
    Utrecht
    MS-Off Ver
    Excel 2013
    Posts
    48

    Re: Update all pivots with column filter

    I have one follow-up question. In the code you described in the previous comment you execute the new filter for ALL Pivotitems, however is it also possible to filter only the column items instead of all pivotitems? (I do not want to include the row filter as well).

    Looking forward to your reply

  8. #8
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    860

    Re: Update all pivots with column filter

    How should I be proposing in the file.
    Can you explain something more specific?

  9. #9
    Registered User
    Join Date
    08-09-2011
    Location
    Utrecht
    MS-Off Ver
    Excel 2013
    Posts
    48

    Re: Update all pivots with column filter

    Hi All,

    Hereby the solution:

    PHP Code: 
    Sub RefreshAllPivotTables()
    Dim PT As PivotTable
    Dim WS 
    As Worksheet
    Dim pi 
    As PivotItem
    Application
    .ScreenUpdating False
        
    For Each WS In ThisWorkbook.Worksheets
           
    For Each PT In WS.PivotTables
              PT
    .RefreshTable
                
    For Each pi In PT.PivotFields("year week").PivotItems
                   pi
    .Visible False
                  
    If pi "201501" And pi "201552" Then pi.Visible True
               Next pi
            Next PT
         Next WS
    End Sub 
    Thanks for the help!

    Cheers, Jeroen

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Refresh All - need to hit it twice to really update all pivots
    By Leszczur in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 10-06-2020, 09:11 AM
  2. Replies: 0
    Last Post: 10-18-2013, 11:35 AM
  3. VBA to change filter for n pivots based on page filter selection for the first pivot
    By shama.arige in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-19-2011, 11:42 AM
  4. Report Filter Update Across Multiple Pivots
    By chicagodc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-27-2010, 03:23 AM
  5. [SOLVED] Update Pivots Dynamically
    By Wayne Huxman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2005, 02:45 PM

Tags for this Thread

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