+ Reply to Thread
Results 1 to 5 of 5

VBA Pivot table filter running too slow

Hybrid View

lynnsong986 VBA Pivot table filter... 04-29-2019, 10:56 AM
XLent Re: VBA Pivot table filter... 04-29-2019, 11:14 AM
lynnsong986 Re: VBA Pivot table filter... 04-29-2019, 11:29 AM
XLent Re: VBA Pivot table filter... 04-29-2019, 11:38 AM
lynnsong986 Re: VBA Pivot table filter... 04-29-2019, 11:45 AM
  1. #1
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    276

    VBA Pivot table filter running too slow

    Hello,

    I have the codes below that loops through a column in rowfield in a pivot table and filters out everything but a given value that is provided through input box.

    the codes took forever to run because the list is very long, is there a faster way of coding this?

    PHP Code: 
    For Each PTItm In pvt.PivotFields("Address").PivotItems
        
    If PTItm.Value Building Then
            PTItm
    .Visible True
        
    Else
            
    PTItm.Visible False
        End 
    If
    Next PTItm 
    thanks,
    Lynn

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: VBA Pivot table filter running too slow

    Untested but you might try applying Manual Update

    With pvt
        .ManualUpdate = True
        For Each PTItm In .PivotFields("Address").PivotItems
            With PTItm
                .Visible = (.Value = Building)
            End With
        Next PTItm
        .ManualUpdate = False
    End With
    note: I'm assuming Building is a variable - else this should be encased within quotations and you might want to remove case sensitivity (c/o UCase on both sides)

  3. #3
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    276

    Re: VBA Pivot table filter running too slow

    Thank you so much XLent, it runs much faster now, very much appreciated.

  4. #4
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: VBA Pivot table filter running too slow

    No problem; for reference the above is akin to using the "Defer Layout Update" option when you update a Pivot table layout via the XL Pivot Field List dialog.

    https://docs.microsoft.com/en-us/off...e.manualupdate

  5. #5
    Forum Contributor
    Join Date
    06-19-2014
    Location
    Toronto, Canada
    MS-Off Ver
    Office365
    Posts
    276

    Re: VBA Pivot table filter running too slow

    great very helpful tips thanks again!

+ 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. Replies: 1
    Last Post: 02-25-2018, 09:47 PM
  2. Two pivot tables with the filter of pivot table 2 to automatically update to filter 1
    By StefaniaLa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2018, 06:19 PM
  3. Advanced Filter Macro Running Slow
    By hellzone in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-08-2015, 10:00 PM
  4. Why my workbook are running filter very slow
    By jatiyanon in forum Excel General
    Replies: 1
    Last Post: 07-21-2015, 12:01 AM
  5. Replies: 6
    Last Post: 07-31-2014, 12:56 PM
  6. Macro is running real slow and makes navigating the worksheet really slow after execution.
    By MichWolverines in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2013, 04:29 PM
  7. Pivot Table VBA Slow
    By JK1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2008, 09:09 AM

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