+ Reply to Thread
Results 1 to 9 of 9

Pivot Table Items

  1. #1
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Pivot Table Items

    Hi all,

    I would like to automate this process described in Debra Link

    http://www.contextures.com/xlPivot03.html#Page

    The attached file is what I've come up with but it's not very dynamic as if I add items etc it won't update.

    Any help/tips would be appreciated

    VBA Noob
    Attached Files Attached Files
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    If you add a couple of dynamic ranges:

    "codes": =OFFSET(Pivot!$E$1,1,0,COUNTA(Pivot!$E:$E)-1,2)
    "pivotdata": =OFFSET(Data!$A$1,0,0,COUNTA(Data!$A:$A),4)

    then change the data source of your to be pivotdata, and alter your code to
    Please Login or Register  to view this content.
    when you add new entries to the Data tab or the list of codes on the Pivot tab and click the button it will refresh everything.


    Col
    If you give someone a program, you will frustrate them for a day; if you teach them how to program, you will frustrate them for a lifetime.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    colofnature,

    Worked a treat

    Thanks

    VBA Noob

  4. #4
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Did you change the pivot table's data source? (Right click the table, select PivotTable Wizard, go back to step 2 of 3 and put pivotdata in the Range box). That done, when the PivotCache.Refresh is executed the dynamic range is used to rebuild the table, and changeing the status of the PivtItems won't cause an error.


    Col

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Done thanks.

    Instead of listing in the sheet would it be possible to populate a userform to select items to show ??

    VBA Noob

  6. #6
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Shouldn't be a problem, you could use a variant of one of my favouritest things, John Walkenbach's GetOption form. Change the radio buttons for checkboxes and hey presto...

    Or just populate the items into a list-box and return the selected items as an array of row numbers (or the sum of 2^row numbers). That would probably be easier.


    C

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Thanks

    Will have a play

    VBA Noob

  8. #8
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    I had to give this a try...
    Please Login or Register  to view this content.
    This will use the form from j-walk, modified to use check boxes, to populate the true/false values in your dynamic range "codes".


    Col

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    colofnature,

    Prefect thanks.

    Only small change I made was to swap the cancel and ok buttons postion numbers.

    VBA Noob

+ 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