+ Reply to Thread
Results 1 to 10 of 10

Loop rows in pivot table

  1. #1
    Registered User
    Join Date
    11-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Loop rows in pivot table

    Hi guys

    I am trying to loop the row data in a pivot table. I have attached a test file for you to have a look.

    So the question is how do i write a code to loop the "Name" colunm in the pivot table?
    or does anyone have a VB code that able to do the loop individually?
    I would appreciate any help i can get.
    Thank you.

    GJH
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor SDruley's Avatar
    Join Date
    04-27-2009
    Location
    Conover, NC
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    415

    Re: Loop rows in pivot table

    An example worksheet is attached
    Attached Files Attached Files
    Turn Data into Information
    Turn Information into Knowledge
    Turn Knowledge into Direction
    Turn Direction into Leadership
    Turn Leadership into Results
    Stephen Druley

    It's not how quickly you think
    But how deeply you think
    The quality of thinking is measured
    by remoteness to conformance
    Stephen Druley

  3. #3
    Registered User
    Join Date
    11-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Loop rows in pivot table

    Thanks for your reply SDruley

    would it be possible to have the pivotitem "Name" to select automatically row by row.
    we dont need pop up message box. Just to have macro to loop row label line by line in the list.

    For example,

    Name Date Result Amended Result
    Alex 15/10/2010 30 36

    then select the next person on the list and deselect 'Alex' and the pivot show

    Name Date Result Amended Result
    John 15/10/2010 50 55

    and etc...

    i hope that is a bit clearer.

    gjh

  4. #4
    Registered User
    Join Date
    11-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Loop rows in pivot table

    here is something that i found on the internet. it's doing the right thing but not in the right field. i would like the loop to run in the "Name" list instead of the page field if that make sense.
    Please Login or Register  to view this content.
    So, i modified the code to:
    Please Login or Register  to view this content.
    but got an error message - unable to set the currentpage property of the pivotfield class

    any help with this error would be great, thanks.
    Last edited by romperstomper; 11-17-2010 at 07:19 PM. Reason: add tags

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Loop rows in pivot table

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Cheers
    Andy
    www.andypope.info

  6. #6
    Registered User
    Join Date
    10-15-2010
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Loop rows in pivot table

    I found this in Excel Forum, maybe this will guide you, good luck.

    [ /]
    http://www.excelforum.com/excel-prog...ivottable.html

  7. #7
    Registered User
    Join Date
    11-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Loop rows in pivot table

    Hi gill389

    thank you for the link, it is really useful. that is exactly what i needed. one last thing, how can i show just one line at a time?
    i might play around the code and see what i can come up.

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

    Re: Loop rows in pivot table

    Please do not simply ignore Andy's request to add tags to your code. It is a forum rule.
    Everyone who confuses correlation and causation ends up dead.

  9. #9
    Registered User
    Join Date
    11-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Loop rows in pivot table

    yup, i will remember that.

    Please Login or Register  to view this content.
    So, i modified the code to:

    Please Login or Register  to view this content.
    Last edited by romperstomper; 11-17-2010 at 07:20 PM. Reason: correct tags

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

    Re: Loop rows in pivot table

    Close - code tags, not quote tags, please. (I've added them for you this time)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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