+ Reply to Thread
Results 1 to 7 of 7

Macro that refreshes pivot tables

  1. #1
    Forum Contributor
    Join Date
    11-05-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    181

    Macro that refreshes pivot tables

    I have a macro that inserts additional columns to my data. The code that I am using to refresh the pivot tables linked to the data does not work. I believe the issue is that the field in the pivot is one of the columns that gets added by macro.

    Is there a pivot table refresh code that can be used to incorporate the now updated data?

    The code I used (that doesn't work):

    Please Login or Register  to view this content.

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Macro that refreshes pivot tables

    Please Login or Register  to view this content.
    The code is untested, but give it a try
    Cheers!
    Deep Dave

  3. #3
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: Macro that refreshes pivot tables

    Out of curiosity, is there a significant difference in pt.PivotCache.Refresh vs. pt.Refresh?
    Want to show appreciation for the help you received from a member? Give them reps by clicking the bottom left of their post!

  4. #4
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Macro that refreshes pivot tables

    I don't think there is really..

    http://www.ozgrid.com/forum/showthread.php?t=80005

    And to be honest, I don't think there is even much of a difference between Post #1 & #2.

    However, It was just a first thought that came to my mind, so its worthwhile testing it once..

    @Sgligori

    Can you attach a sample workbook?

  5. #5
    Forum Contributor
    Join Date
    11-05-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    181

    Re: Macro that refreshes pivot tables

    Hi NeedforExcel, attached is what my data and linked pivots look like. Running the code below will work just fine (my intention is to get it to filter for each VP in the pivot tables). But if you were to delete all of the rows except for, say, the top 10, and try to rerun the code, the code will not filter for each VP. I get a "Run Time error 1004" message (application defined or object defined error). Since this code will be used as a template, I have to be able to account for the row count changing week to week.

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

  6. #6
    Forum Contributor
    Join Date
    11-05-2014
    Location
    Charlotte
    MS-Off Ver
    2013
    Posts
    181

    Re: Macro that refreshes pivot tables

    I found that refreshing the pivot cache solves the problem. I used the code below.

    Please Login or Register  to view this content.

  7. #7
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Macro that refreshes pivot tables

    Great!

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Auto-Refresh Pivot Table When Source Data Refreshes
    By XLINT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2015, 11:00 AM
  2. [SOLVED] Select item of a dropdown list (data validation) and refreshes values of all pivot tables
    By siroco79 in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 03-06-2014, 05:35 AM
  3. Creating a Master / Consolidated Pivot Tables from a multiple pivot tables
    By paradise2sr in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 12-12-2013, 02:28 AM
  4. Replies: 0
    Last Post: 07-25-2013, 05:24 PM
  5. [SOLVED] Pivot table doesn't refreshes
    By pic2pic in forum Excel General
    Replies: 4
    Last Post: 01-20-2013, 05:27 AM
  6. Macro that refreshes/sort information
    By SeanKosmann in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-27-2010, 04:01 PM
  7. Stock Macro for web query refreshes
    By mtj2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2008, 02:44 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