+ Reply to Thread
Results 1 to 3 of 3

Pivot Table - unable to set visible property?

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Pivot Table - unable to set visible property?

    I am trying to write code that will display data for the appropriate month selected by the user. I have attached a sample file that has the following error:
    "Unable to set the visible property of the pivot item class."
    Thank You in advance
    Attached Files Attached Files
    Last edited by Aland2929; 07-19-2010 at 06:13 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,973

    Re: Pivot Table - unable to set visible property?

    Change your OK button code to this:
    Private Sub OKButton_Click()
        Dim pt As PivotTable, pi As PivotItem
        Dim DateChosen As String
        
        Application.ScreenUpdating = False
        
        Set pt = Sheets("Pivot").PivotTables("ChannelSummary")
        DateChosen = ListBox1.Value
        
        With pt
            .ManualUpdate = True
            .PivotFields("Month").PivotItems(DateChosen).Visible = True
            For Each pi In .PivotFields("Month").PivotItems
                If pi.Name <> DateChosen Then pi.Visible = False
            Next pi
            .ManualUpdate = False
        End With
        
        Unload Me
    End Sub
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    854

    Re: Pivot Table - unable to set visible property?

    Thank you very much Romperstomper. It works perfectly. I will work through it to understand it.

+ 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