+ Reply to Thread
Results 1 to 3 of 3

Need help for VBA code - pivot table updates

  1. #1
    Registered User
    Join Date
    10-31-2014
    Location
    canada
    MS-Off Ver
    2007
    Posts
    64

    Need help for VBA code - pivot table updates

    Hi,

    My file has one data sheet (tab name "Data") which contains daily data and other 2 sheets which contain several pivot tables. The number of records are not constant on a daily basis (columns are the same, but the rows are changing, sometimes has more rows, sometimes has less rows). Currently, I have to manually update all pivot tables by clicking "Analyze" on tool bar, select "Change Data Source", and select the entire records, and finally refresh pivot tables.

    What I am looking for is using VBA code to automatically select all the records in "Data" tab, and update all pivot tables based on the selected data. I've tried to search some codes online, but none of them is successful. Is there anyone here can help me this? Thanks in advance.

    Chris

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,902

    Re: Need help for VBA code - pivot table updates

    You don't need VBA for this.

    There are few ways to make data source for PivotTables dynamic. Here's 2 recommended ones.

    1. Convert data range to Excel Table. Reference the table by name for Pivot data source.

    2. Create Dynamic Named range for the data range. Use that for your pivot table source.

    For the 2nd option, see link for details. If you have trouble recreating on your file. Upload sample file and I can take a look at it.
    http://excelpivots.com/excel/pivot_t...g_data_ranges/
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: Need help for VBA code - pivot table updates

    Set the range for your pivot table to the entire column(s), e.g. header is in A1:E1, data is A2:E[ ] set pivot table source to A:E

+ 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. Need help with drop down on one page that updates a pivot table on another
    By ajmarti82 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2016, 04:44 PM
  2. Using code which updates Pivot Table...
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-13-2015, 05:28 PM
  3. [SOLVED] Pivot Table with range that auto updates
    By drewmey in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-02-2014, 07:33 PM
  4. pivot table error but still updates
    By Hakara in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-19-2012, 01:35 PM
  5. Drill Down Updates from a Pivot Table linked to a table
    By BON1985 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-21-2012, 10:18 AM
  6. How to unhide row as pivot table updates
    By adsm in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 04-26-2010, 01:50 PM
  7. Pivot Table - Updates
    By wal50 in forum Excel General
    Replies: 2
    Last Post: 01-29-2005, 11:06 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