+ Reply to Thread
Results 1 to 10 of 10

Pivot VBA: Inserting Row label on last position before the data values start.

  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    Karlsruhe, Germany
    MS-Off Ver
    Excel 2007
    Posts
    9

    Pivot VBA: Inserting Row label on last position before the data values start.

    Hi,
    I am not expert on VBA, I can only do the very basics and record the commands.
    I have the following code:
    Please Login or Register  to view this content.
    What I want to do is insert the desired field on the last column position before the data values start on the pivot. So I don't know which condition I have to apply if I don't want this field's position to be binded to a fixed number like 3 on the code.

    Thanks in advance!

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

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    if you remove the .position line the default should be to add the field as the last row field
    Josie

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

  3. #3
    Registered User
    Join Date
    11-22-2012
    Location
    Karlsruhe, Germany
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    Yeap That's right!
    I was looking all over internet for hours and couldn't find any problem like mine. Thanks!
    Regarding the same code I have another issue. You know that we can play around with the table, adding fields as row labels, column labels,etc. I wanted to create a button to reset this changes that people might do to a standard layout of the pivot.
    Here is a sample of what I have now
    Please Login or Register  to view this content.
    As shown, it removes the Plant Supplier that we inserted on the first code above, whatever the position is as row label. But the thing is I have this pattern that I call standard pivot and people might work around it and get some report filters and put them as row labels and vice-versa.

    Is there any solution instead of clearing all the contents and starting from 0, and doing all the formatting once more...

    Thanks again!

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

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    not really-you can use the addfields method of the pivot table to replace all row and column fields with the ones you want but for filter/page fields and data fields it's easiest to simply clear the table and start again

  5. #5
    Registered User
    Join Date
    11-22-2012
    Location
    Karlsruhe, Germany
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    Ok thanks anyway.. thats what I thought.
    Could you send me the link if there is any to this addfields method?

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

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    look it up in the VBA help files and/or the object browser ;-)

  7. #7
    Registered User
    Join Date
    11-22-2012
    Location
    Karlsruhe, Germany
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    Alright!
    Last question.. I was trying to insert the Report filters back on once they were hidden from the row labels and it somehow doesn't work...

    Please Login or Register  to view this content.
    Is it possible to build the report filters via code? because they are not working

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

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    you have a typo-you have x1PageField but it should be xlPageField (with L instead of 1)

  9. #9
    Registered User
    Join Date
    11-22-2012
    Location
    Karlsruhe, Germany
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    Sweet! Thanks dude.. You were very helpful with my stupid, newbie questions :D

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

    Re: Pivot VBA: Inserting Row label on last position before the data values start.

    you're welcome :-)

    please don't forget to mark the thread solved

+ 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