+ Reply to Thread
Results 1 to 6 of 6

Error 1004 unable to set the visible property of the pivotitem class

Hybrid View

4am Error 1004 unable to set the... 02-02-2012, 04:41 PM
jomili Re: Error 1004 unable to set... 02-03-2012, 10:41 AM
4am Re: Error 1004 unable to set... 02-07-2012, 12:33 PM
jomili Re: Error 1004 unable to set... 02-07-2012, 01:28 PM
4am Re: Error 1004 unable to set... 02-23-2012, 10:40 AM
jomili Re: Error 1004 unable to set... 02-23-2012, 10:46 AM
  1. #1
    Forum Contributor
    Join Date
    04-14-2008
    Location
    Fort Collins, Co
    MS-Off Ver
    2016
    Posts
    107

    Error 1004 unable to set the visible property of the pivotitem class

    Got some great code help from someone here yesterday and it worked fine. The code works great the first time I run it. But if I try to make a different selection in the drop down, it errors out (Error 1004 unable to set the visible property of the pivot item class)

    If I close the workbook without saving and reopen, it will work one time.


    Sub SomePivots()
    '---------------------------------------------------------------------------------------
    ' Procedure : SameSelection
    ' Date      : 2/1/2012
    ' Purpose   : Updates all Pivots in array of worksheets
    '---------------------------------------------------------------------------------------
    
    Dim P As PivotTable
        Application.ScreenUpdating = False
        Dim sh As Worksheet
    For Each sh In Worksheets(Array("XXXX"))
        For Each P In sh.PivotTables
            With P.PivotFields("XXXX")
    
            'Show all pivotitems
            For IndexCtr = 1 To .PivotItems.Count
                .PivotItems(IndexCtr).Visible = True
            Next IndexCtr
    
            'Display only what's in cell I1
            On Error GoTo BadNews
            For i = 1 To .PivotItems.Count
                If .PivotItems(i).Name Like Sheets("XXXX").Range("V6").Value Then
                    .PivotItems(i).Visible = True
                Else
                    .PivotItems(i).Visible = False
                End If
            Next i
        End With
        Next
        Next
        Application.ScreenUpdating = True
        Exit Sub
    BadNews:
        Application.ScreenUpdating = True
        MsgBox "XXXX not found this month. There may be no XXXX associated with this XXXX. If you feel you have reached this message in error, email XXXX@XXX.com"
        Exit Sub
    
    End Sub
    Is That Your Spreadsheet Or Did Your Database Just Throw Up?


  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Re: Error 1004 unable to set the visible property of the pivotitem class

    4am, can you post your workbook so we can see it in action?

  3. #3
    Forum Contributor
    Join Date
    04-14-2008
    Location
    Fort Collins, Co
    MS-Off Ver
    2016
    Posts
    107

    Re: Error 1004 unable to set the visible property of the pivotitem class

    I wish I could! Company policy, can't do it. Plus, it's 54mb! I am unsure of how to handle this issue, but I guess I will figure it out... Thank you

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Re: Error 1004 unable to set the visible property of the pivotitem class

    The error you mentioned means it can't find the value of your dropdown selection among the pivotitem choices. Try putting
    Option Compare Text
    at the top of the module to make it non-case sensitive. This will ensure that whether you choose "a" or "A" that the correct value will be chosen. Without that option an error such as you're describing could happen.

    I've posted a new sample workbook, tested to ensure it will work no matter what the selection. Give it a whirl (go to Sheet 1)
    Attached Files Attached Files
    Last edited by jomili; 02-07-2012 at 01:45 PM.

  5. #5
    Forum Contributor
    Join Date
    04-14-2008
    Location
    Fort Collins, Co
    MS-Off Ver
    2016
    Posts
    107

    Re: Error 1004 unable to set the visible property of the pivotitem class

    YOU Jomili are a GENIUS! Thank you so much you have saved the day!

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Re: Error 1004 unable to set the visible property of the pivotitem class

    Well, much as I appreciate the sentiment, I'm only passing on what kind souls have passed to me. But you CAN add to my repution if you'd like; that wouldn't bother me much.

+ 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