+ Reply to Thread
Results 1 to 9 of 9

Excel 2010 VBA: Last Row in Pivot Table

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    11

    Excel 2010 VBA: Last Row in Pivot Table

    Please Login or Register  to view this content.
    Hi All

    I am trying to assign the last row of a Pivot Table to a variable.

    I have tried the two statements above in the immediate window that I found on another thread, but it is not always referencing the last row.

    Help!

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Excel 2010 VBA: Last Row in Pivot Table

    I personally use this, but depending on what you have in your pivot table, the last row of may have a different name from "Grand Total"

    Please Login or Register  to view this content.

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel 2010 VBA: Last Row in Pivot Table

    Please Login or Register  to view this content.
    oughta always work
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  4. #4
    Registered User
    Join Date
    08-01-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Excel 2010 VBA: Last Row in Pivot Table

    Hi All

    I just get the last used row with the first method which is often well beyond the last row of the Pivot
    The 2nd method, doesn't seem to work everytime either, not sure why. I have multiple worksheets each with just one pivot on, and when I run this in the immediate window it works for some and not others.

    Anything more robust?

  5. #5
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Excel 2010 VBA: Last Row in Pivot Table

    Well I use it with 0 problems. You probably didn't change the column letter to the column where your pivot table starts. Anyway, if the other method works better, then just use that.

    If it's only working sometimes, then are you sure you are referencing the correct pivot table? In case you are not sure, PivotTables(1) references only the first pivot table in your worksheet.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Excel 2010 VBA: Last Row in Pivot Table

    Tablerange1 refers to the range of the Pivottables at the time. No ifs ands or buts. If you can provide something that shows otherwise I will be happy to bug it, but otherwise you are incorrect.
    Everyone who confuses correlation and causation ends up dead.

  7. #7
    Registered User
    Join Date
    08-01-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Excel 2010 VBA: Last Row in Pivot Table

    Thanks All

    You were right! I had the wrong Column Letter!

  8. #8
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Excel 2010 VBA: Last Row in Pivot Table

    Glad you fixed it.



    Quote Originally Posted by romperstomper View Post
    Tablerange1 refers to the range of the Pivottables at the time. No ifs ands or buts. If you can provide something that shows otherwise I will be happy to bug it, but otherwise you are incorrect.
    Who were you talking to?

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,971

    Re: Excel 2010 VBA: Last Row in Pivot Table

    To the OP of course since he said that Tablerange1 did not always work.

+ 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. Excel 2010 Pivot table
    By geeka in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 08-29-2013, 05:51 AM
  2. A problem with the pivot table at excel 2010?
    By georgechatzi in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-11-2012, 11:50 AM
  3. [SOLVED] Excel 2010 Pivot Table overlap
    By Delta729 in forum Excel General
    Replies: 1
    Last Post: 10-07-2012, 03:41 AM
  4. Excel 2010 Pivot table
    By DizzyMoe in forum Excel General
    Replies: 5
    Last Post: 03-28-2012, 12:13 PM
  5. Excel 2010 - Pivot Table Chart
    By jmancha in forum Excel General
    Replies: 5
    Last Post: 08-22-2011, 11:12 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