+ Reply to Thread
Results 1 to 4 of 4

using VBA with getpivotdata on a variable number of rows

  1. #1
    Registered User
    Join Date
    10-24-2010
    Location
    Melbourne, Aust
    MS-Off Ver
    Excel 2007
    Posts
    19

    using VBA with getpivotdata on a variable number of rows

    Hi,

    Im making a table with time (0 - 23) on the top and location along the side. Each cell in the table should take data from a pivot table. When I do this manually in Excel I get this:

    =GETPIVOTDATA("time round",Sheet5!$A$3,"Station","120 Collins St","group 1",7)

    In order to copy this to all the cells in the sheet I replace the "120 Collins St" with it's cell reference. and I do this with the 7 too.

    =GETPIVOTDATA("time round",Sheet5!$A$3,"Station",$A2,"group 1",I$1)

    I would like to create a macro that will do this for me. However, the macro will have to be able to cope with an undetermined number of rows. Perhaps through using 'lastrow'.

    It would be also useful to include the ISERROR function so that zero is displayed in the cell in the case that the pivot table does not have the value corresponding to the table.

    Can anyone help me design a macro for this?

  2. #2
    Registered User
    Join Date
    10-24-2010
    Location
    Melbourne, Aust
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: using VBA with getpivotdata on a variable number of rows

    bump! bump!

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: using VBA with getpivotdata on a variable number of rows

    Bumping a post after less than 2 hours over a weekend is not really the "done thing"

    If you're using XL2007 as implied

    Please Login or Register  to view this content.
    modify sheetname etc as necessary

  4. #4
    Registered User
    Join Date
    10-24-2010
    Location
    Melbourne, Aust
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: using VBA with getpivotdata on a variable number of rows

    Hi,

    Thanks a lot for this post.

    I have tried it and changed it a little to use if(iserror etc and it works great.

    Thanks, legend.

    bump

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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