+ Reply to Thread
Results 1 to 3 of 3

Refering to a pivotTable in vba

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Refering to a pivotTable in vba

    I have a worksheets with two PivotTables on each. I use the following sub to refresh them.
    Please Login or Register  to view this content.
    The tables in the first sheet are labelled 1 and 2 and they both refresh as expected.
    The tables in the second sheet are labelled 1 and 4. Excel labelled these for me, probably using 4 because I had several attempts at arranging this table.
    The Pivottable 1 refreshes pivottable 4 does not but gives an error message "Unable to get PivotTable of the worksheet class" which I take to mean that it can't find PivotTable4
    Why should this be so, and what should I do to solve the problem?
    John

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

    Re: Refering to a pivotTable in vba

    Why refresh individually?

    You can simply use...
    Please Login or Register  to view this content.
    To refresh all pivot tables.

    If for some reason, you need to refresh individually. Try checking for name using something like below.
    Please Login or Register  to view this content.
    ?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
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: Refering to a pivotTable in vba

    CK76
    I have to refresh separately because the second pivot takes the first plus some calculated columns as its input.
    I used your demo sub and this confirmed that the pivot in question was called Table4. I can't see any typos so I am at a loss as what to do.
    I am going to change the table name to Table2 and see what happens.
    John

+ 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. After updating PivotTable Source data with Macro, slicer doesn't show PivotTable
    By mrdouglaswee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2018, 02:10 AM
  2. Create PivotTable Based On A PivotTable
    By goss in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-10-2014, 03:47 PM
  3. Replies: 0
    Last Post: 01-07-2013, 08:39 PM
  4. Copied a tab with a pivottable and pivottable graph
    By Dinger045 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-13-2012, 01:35 PM
  5. Shift rows below PivotTable down when PivotTable expands (PowerPivot)
    By hektisk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-06-2012, 10:19 PM
  6. refering to different sheets
    By vigo in forum Excel General
    Replies: 0
    Last Post: 08-06-2008, 01:55 AM
  7. Refering to Cells
    By madh83 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-19-2006, 06:40 PM

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