+ Reply to Thread
Results 1 to 8 of 8

Speeding up creating worksheets based upon items in pivot table

  1. #1
    Registered User
    Join Date
    08-17-2016
    Location
    Amsterdam
    MS-Off Ver
    2013
    Posts
    14

    Speeding up creating worksheets based upon items in pivot table

    Hi members,

    This is a repost, but this time with the attachment added (hopyfully)

    I have a workbook for which i want to create new worksheets for every item in the filter selection.
    Since i want to modify the created worksheets and only keep the values and not the pivot itself, i created a code which seems to work, but is quite slowly.

    Is there a way how i can speed up this code?

    Please Login or Register  to view this content.
    I cannot seem to upload the file ....
    The problem is that the following code

    "For Each PI In Worksheets(MyWs).PivotTables(MyPIV).PivotFields(MyField).PivotItems
    PI.Visible = True

    For Each PI2 In Worksheets(MyWs).PivotTables(MyPIV).PivotFields(MyField).PivotItems
    If Not PI2.Name = PI.Name Then PI2.Visible = False
    Next PI2'"

    is comparing each item to each other (>500 options).

    What i actually want is that the code will unselect all items, except for each PI in worksheet but do not seem to get the code working.
    Goal is to unselect all items in pivot table and then only choose the unique PI and create a new worksheet for it. I want to continue doing this, untill all worksheets has been created
    Attached Files Attached Files
    Last edited by hdinkie; 09-23-2016 at 01:34 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Speeding up creating worksheets based upon items in pivot table

    Hi hdinkie

    If I understand try this Code...
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    08-17-2016
    Location
    Amsterdam
    MS-Off Ver
    2013
    Posts
    14

    Re: Speeding up creating worksheets based upon items in pivot table

    Hi Jaslake,

    Thank you for your reply!
    This code is creating the worksheets as i was hoping for, but there is one problem in the code.
    For each PI in pivottable, it should select the filter of only that specific PI.

    The attachment is a little bit confusing, as all description in column C has a "A" in it, but this was done for the anonymization of the file.
    The description in column C could differ for each PI.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Speeding up creating worksheets based upon items in pivot table

    Hi hdinkie

    This, I'd assume, is good...
    This code is creating the worksheets as i was hoping for
    This I have no clue...
    For each PI in pivottable, it should select the filter of only that specific PI.
    Perhaps it's related to this...
    all description in column C has a "A"
    and this...
    The description in column C could differ for each PI.
    Please clarify by attaching a sample workbook the Structure of which is the same as your actual workbook.

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    INCLUDE ANY CODE YOU'RE USING OR HAVE TRIED.

    Remember to desensitize the data.

    To do this, click on Go Advanced (below the Edit Window) while you are composing a reply, then scroll down to and click on Manage Attachments and the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.

  5. #5
    Registered User
    Join Date
    08-17-2016
    Location
    Amsterdam
    MS-Off Ver
    2013
    Posts
    14

    Re: Speeding up creating worksheets based upon items in pivot table

    Hi Jaslake,

    Sorry for the confusing, see hereby the attachments of a before and after file.

    Hope this clarifies and you know a way that would remove the loop. Thanks a lot!

    ps: i know limited the possible items to 25 just items, but the more items the slower the code will run. In my original file i have about 500 items ....
    Attached Files Attached Files
    Last edited by hdinkie; 09-24-2016 at 07:01 PM.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Speeding up creating worksheets based upon items in pivot table

    Hi hdinkie

    See if this Code in the attached does as you require...
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    08-17-2016
    Location
    Amsterdam
    MS-Off Ver
    2013
    Posts
    14

    Re: Speeding up creating worksheets based upon items in pivot table

    Wowww, this was exactly what i was looking for !
    Thanks a lot Jaslake!

    Have been trying to speed up the loop for quite a while now

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Speeding up creating worksheets based upon items in pivot table

    You're welcome...glad I could help. Thanks for the Rep.

+ 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] Speed up creating worksheets for all filters in pivot table
    By hdinkie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2016, 08:01 AM
  2. Replies: 1
    Last Post: 07-16-2015, 05:46 AM
  3. Replies: 10
    Last Post: 01-08-2013, 04:03 PM
  4. Replies: 0
    Last Post: 05-28-2012, 02:43 AM
  5. Creating a pivot table from multiple worksheets in one workbook
    By kiran654 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-20-2010, 07:25 PM
  6. Populate combo box based on Pivot Table Field items
    By Khaos176 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2009, 07:33 PM
  7. [SOLVED] creating a pivot table w/ ranges from 2 worksheets
    By tl in forum Excel General
    Replies: 1
    Last Post: 08-20-2005, 03:05 PM

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