+ Reply to Thread
Results 1 to 4 of 4

Dynamically Positioning PivotItems in VBA

  1. #1
    Registered User
    Join Date
    01-27-2015
    Location
    Melbourne, FL
    MS-Off Ver
    2010
    Posts
    2

    Exclamation Dynamically Positioning PivotItems in VBA

    I created a pivot table in VBA that works fine, the columnfield is based on a work order type. "WO Type", I need to have the WO Types in a specific position 1 - x . I have the code written out for each different type but the code fails the first instant that one of the WO Types is not present. I thought about using an array and using Do While incrementally increasing the position # for each WO Type that is present but it throws itself into an endless loop. Hoping there is a way to do this, just don't know how.. Any help would be GREATLY appreciated!

    Here is the code that I have so far. There is two different schools of thought here, I left both, the code doesn't work either way. Hoping someone has an easy fix!

    Please Login or Register  to view this content.
    Last edited by VBA_NOOB1; 01-27-2016 at 09:09 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Dynamically Positioning PivotItems in VBA

    Firstly ,you mistyped pvtitems
    Please Login or Register  to view this content.
    not sure your error trapping is working properly
    try this code instead

    Please Login or Register  to view this content.
    Last edited by humdingaling; 01-27-2016 at 07:14 PM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    01-27-2015
    Location
    Melbourne, FL
    MS-Off Ver
    2010
    Posts
    2

    Re: Dynamically Positioning PivotItems in VBA

    Thanks Humdingaling, this almost works. The issue is, when PMB is present, the code provided works perfectly. When it is NOT present, the code takes the last item in the array and puts it first THEN organizes the rest correctly. Is there a way to keep the order that is listed in the array?

    Thanks a bunch!

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Dynamically Positioning PivotItems in VBA

    Please Login or Register  to view this content.
    Last edited by humdingaling; 01-27-2016 at 07:31 PM. Reason: actually Ubound(arrpiv) is a better option

+ 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. [SOLVED] Selecting a few of many pivotitems
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-22-2015, 10:36 AM
  2. VBA to remove PivotItems
    By LB79 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-24-2013, 10:34 AM
  3. .pivotitems().visible with UDF
    By apistilli in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-24-2012, 03:09 PM
  4. set pivotitems visible
    By hiddy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2010, 06:34 AM
  5. Pivotfields & Pivotitems VBA
    By pickledmuffin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-08-2008, 06:12 PM
  6. [SOLVED] Adding PivotItems
    By Geoff in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-12-2006, 04:15 AM
  7. [SOLVED] Always keep the same 4 PivotItems visible
    By Martin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2005, 06:06 AM

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