+ Reply to Thread
Results 1 to 7 of 7

How do I selectivly refresh pivottables in a workbook?

  1. #1
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    How do I selectivly refresh pivottables in a workbook?

    Hi All,

    I have two worksheets each containing a few pivottables. I would only want to refresh 3 pivot tables out of a possible 10 in this workbook.
    From the below code, pivottable 1 and 4 is on one worksheet, pivottable 8 is on another - the code will need to go through all the pivot tables in the workbook and update these 3 only.

    I have attempted the below code but there is an error. Can someone please let me know what is wrong.

    Thanks!

    Please Login or Register  to view this content.
    Last edited by swong1709; 02-12-2015 at 09:58 PM.

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

    Re: How do I selectivly refresh pivottables in a workbook?

    There's not a lot of point in looping - you can just refresh them directly:
    Please Login or Register  to view this content.
    for example.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Re: How do I selectivly refresh pivottables in a workbook?

    Quote Originally Posted by romperstomper View Post
    There's not a lot of point in looping - you can just refresh them directly:
    Please Login or Register  to view this content.
    for example.
    Thanks! Trying to overcomplicate things.

  4. #4
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Re: How do I selectivly refresh pivottables in a workbook?

    Quote Originally Posted by romperstomper View Post
    There's not a lot of point in looping - you can just refresh them directly:
    Please Login or Register  to view this content.
    for example.
    Hi, On top of this, can i use the sheet index like .sheets(1).pivottables("name").refreshtable??

    Users may be changing the sheet name and the code will not work.

    Thanks

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

    Re: How do I selectivly refresh pivottables in a workbook?

    Yes but it would be safer (in case the users move things) to use the code name assuming the code is in the same workbook.

  6. #6
    Registered User
    Join Date
    02-07-2014
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    52

    Re: How do I selectivly refresh pivottables in a workbook?

    What do you mean the code name.
    I tried using sheets(8).pivottables("name").refreshtable but it doesn't work.

    Thanks

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

    Re: How do I selectivly refresh pivottables in a workbook?

    In the Project Explorer window in the VB Editor, you will see for each sheet a name followed by another name in parentheses - e.g. Sheet1 (some sheet)

    Sheet1 is the codename (the name in parentheses is what you see on the sheet tab) and can be used as a variable:
    Please Login or Register  to view this content.
    It is usually best to rename the codename to something more meaningful using the properties window.

+ 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. Annoying bug (?) in PivotTables that don't refresh properly
    By pbengtss in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 01-07-2015, 09:24 AM
  2. Finding PivotTables in the Workbook
    By emilesilvis in forum Excel General
    Replies: 2
    Last Post: 06-15-2011, 06:56 AM
  3. Refresh PivotTables with OLE Automation and MS Excel 2007
    By sgovoni in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-28-2010, 08:54 AM
  4. Replies: 0
    Last Post: 10-01-2008, 11:14 AM
  5. [SOLVED] Re: How to refresh dropdown lists in PivotTables?
    By Eleanor M in forum Excel General
    Replies: 6
    Last Post: 03-03-2006, 10:15 AM

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