+ Reply to Thread
Results 1 to 12 of 12

Unable to set the visible property of the PivotItem class

  1. #1
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Unable to set the visible property of the PivotItem class

    Hello,

    I am trying to control the filters of a pivot table according to the .text of 2 combo boxes.

    Everything works OK until I try to changing from visible to not visible certain items.

    Here's my code:


    Please Login or Register  to view this content.
    I have read that it might be a bug, but it's been in forum posts from long ago, an it was solved with:

    Please Login or Register  to view this content.
    Nevertheless, in my case it still displays the following error when I execute this code:

    Please Login or Register  to view this content.
    I am using MS Excel 2007. I would much appreciate your assistance.
    Last edited by RagonichaFulva; 02-27-2012 at 07:22 AM.

  2. #2
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Unable to set the visible property of the PivotItem class

    I read that I can have this error if there is no other pivot item visible, but if I try to make visible all the items and then hide the ones I don't want to show it still crashes:

    Please Login or Register  to view this content.
    On the other hand, if I use the recorded version it works:

    Please Login or Register  to view this content.
    This is so weird... :S

  3. #3
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Unable to set the visible property of the PivotItem class

    I have read in MSDN that it's a bug in MS Excel. You can't change the visibility of two contiguous pivot items.

    The solution might be to go through them jumping a pivot item at a time in two loops.

    I'll give it a try.

  4. #4
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Unable to set the visible property of the PivotItem class

    Finally I could solve it looping through the Pivot field twice with the following code:

    Please Login or Register  to view this content.
    It isn't very effficient, but it avoids the problem of contiguous pivot items.

  5. #5
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Unable to set the visible property of the PivotItem class

    No way, it still displays the error.

    How can MS doesn't solve this bug? It's been there for a long, long time...

  6. #6
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Unable to set the visible property of the PivotItem class

    I had to use the following code, but it depends on public variables and in case of a crash of the excel workbook I was screwed...

    Please Login or Register  to view this content.
    I used previousfilter as a global variable to store the filter I must remove, but in the end i transformed it into an array that stores all the active filters and then I hide them individually.

    It is sad to have to use this tricks to do such a simple operation:

    Please Login or Register  to view this content.
    Hope this is useful for someone else.

  7. #7
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Unable to set the visible property of the PivotItem class

    I can't say I have a problem hiding contiguous items in a pivot table. Are you sure you aren't hiding all of them?
    Good luck.

  8. #8
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Unable to set the visible property of the PivotItem class

    Quite sure.

    Now I have found the error. It's a problem of making visible the elements in the first place, and then hide the ones Ia m interested. the error comes when you try to hide the only item that is visible.

    So the code ends up like this:

    Please Login or Register  to view this content.
    Now if you excuse me, I am going to bump my head against the table as a punishment for my clumsiness...

    I read so much about the contiguous issue I gave for certain the problem might be there.

  9. #9
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Unable to set the visible property of the PivotItem class

    So you were trying to hide all of them (albeit not on purpose)...

  10. #10
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Unable to set the visible property of the PivotItem class

    Quote Originally Posted by OnErrorGoto0 View Post
    So you were trying to hide all of them (albeit not on purpose)...
    Well... I must say in my defense that it was only sometimes... when the filter to show was tha bottom of the Pivot field... :P

    Thanks for the assistance.

  11. #11
    Registered User
    Join Date
    08-28-2012
    Location
    Orange County, CA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Unable to set the visible property of the PivotItem class

    Ugh. Literally 6 hours of coding/searching/reformatting solved by that one rearrangement.
    Thank you.

  12. #12
    Registered User
    Join Date
    11-28-2011
    Location
    Barcelona
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Unable to set the visible property of the PivotItem class

    Nice.

    Great to hear that.

+ 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