+ Reply to Thread
Results 1 to 11 of 11

PivotTable refresh is extremely slow

  1. #1
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    PivotTable refresh is extremely slow

    My workbook updates multiple pivot tables with the code below. This works fine when processing smaller amounts of data, but it severely lags when processing large amounts of data. It shouldn't be taking that long to make the updates. Is there a more efficient way for me to update all of my pivot table? They all use the same source data from the Data worksheet.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: PivotTable refresh is extremely slow

    If you use a Table or dynamic range for the source data, you won't need to change it - you'll just need to refresh the tables. As it is, your code actually refreshes everything twice which isn't helping the speed.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: PivotTable refresh is extremely slow

    Thanks for the reply. I feel like I'm in over my head on this. I created a dynamic data range (DataRange), but the code errors out on the pt.RefreshTable and the dynamic data range name (DataRange) breaks down and puts in#REF! instead of the desired refence cells.

    DataRange name function Before code runs:
    Please Login or Register  to view this content.
    DataRange name function After code runs:
    Please Login or Register  to view this content.
    VBA Code Error here:
    Please Login or Register  to view this content.
    I also tried to use pt.ManualUpdate = True/False to try to speed up the code, but the tables don't refresh until I manually hit the refresh all button once the code finishes (it does run faster this way though).
    Please Login or Register  to view this content.
    Last edited by Platinum3x; 12-11-2014 at 11:47 AM.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: PivotTable refresh is extremely slow

    Does your code delete rows on the data sheet?

  5. #5
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: PivotTable refresh is extremely slow

    Yes, it essentially pulls in data from another excel workbook and pastes it into the Data tab of my workbook where all these macros are. Then it uses that source data on the Data tab to update all the pivot tables on the various sheets. So, when that new source data gets copied over to the Data tab worksheet, I'm sure it's messing with the OFFSET formula of my dynamic range.

  6. #6
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: PivotTable refresh is extremely slow

    Right now I'm forced to set the source data or else I get an error. The pivot tables will change source data ranges on me:

    If I don't use this:
    Please Login or Register  to view this content.
    I will get this error (if just using pivot table refresh):
    Please Login or Register  to view this content.

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: PivotTable refresh is extremely slow

    What's the code that pulls in the new data? There should be no reason for it to actually delete cells - if it just clears them, you shouldn't have a problem with the dynamic range, or a Table which would be simpler.

  8. #8
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: PivotTable refresh is extremely slow

    Here's the start of my code that brings in the new source data as the first step. I do see the second line where I'm deleting the UsedRange on the Data sheet (where the new data will be put). Should I remove that line of code and replace it with something that "clears" the cells and doesn't delete them?

    Please Login or Register  to view this content.
    Thanks,

  9. #9
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: PivotTable refresh is extremely slow

    Try changing that to:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    10-17-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    71

    Re: PivotTable refresh is extremely slow

    Awesome, I think it is working! I had to define my dynamic range in VBA before the pivot table refresh, otherwise the function resets with REF# for the ranges. Included this:

    Please Login or Register  to view this content.
    Now I can just use the pt refresh and it goes SO much faster! THANKS SOOOO MUCH MAN!

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: PivotTable refresh is extremely slow

    Glad to help.

+ 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: 12-04-2014, 04:13 PM
  2. Replies: 0
    Last Post: 01-07-2013, 08:39 PM
  3. Extremely slow macro!
    By PSm1th29 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2010, 06:27 AM
  4. FileCopy extremely slow
    By Idiot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2008, 12:10 AM
  5. Extremely slow file
    By Jay in forum Excel General
    Replies: 3
    Last Post: 07-10-2006, 08:19 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