+ Reply to Thread
Results 1 to 2 of 2

error 1004: unable to set the visible property of the pivotitem class

Hybrid View

  1. #1
    Registered User
    Join Date
    06-24-2014
    Location
    Milan, Italy
    MS-Off Ver
    2010
    Posts
    6

    error 1004: unable to set the visible property of the pivotitem class

    Hi, I use Excel 2010 andexample.xlsx cannot make my code working because of the so famous errore above. I was unable to find a solution reading previous posts, so hope anyone can help me.

    I have several pivot tables (pt) in different worksheets (ws), and a list of items stored in an array I created. I've written a macro for setting ON all items in pt except those ones in the array (listOffnet within the code). Everything works properly.

    Now, I would like to do the complementary action: setting OFF all items that are not in the array. Unfortunately, I get the error at line

    pvtItm.Visible = False
    Many thanks! This is my code:

    Sub ptFilterOffnet()
    
    Dim PvtTbl As PivotTable
    Dim pvtItm As PivotItem
    Dim pvtFld As String
    Dim listItem As Variant
    Dim listOffnet As Variant
    Dim lastRow As Integer
    Dim myws As String
    
    pvtFld = "CATEGORY_DESCRIPTION"
    myws = "GESTIONE_ADMIN"
    
    resetSlicers 'function resetting all slicers connected to pivot tables (all items ON)
    
    ' Populate the array with some data in a specific range
    lastRow = Sheets(myws).Cells(Rows.Count, 10).End(xlUp).Row
    listOffnet = populateArray(myws, 3, lastRow, 10, 10)
    
    ' All OFF but items within listOffnet
    For Each PvtTbl In Sheets("P1").PivotTables
        For Each pvtItm In PvtTbl.PivotFields(pvtFld).PivotItems
            For Each listItem In listOffnet
                If pvtItm <> listItem Then
                    pvtItm.Visible = False
                End If
            Next      
        Next
    Next
    End Sub

  2. #2
    Registered User
    Join Date
    06-24-2014
    Location
    Milan, Italy
    MS-Off Ver
    2010
    Posts
    6

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

    Example attachment

    Thanks
    Attached Files Attached Files

+ 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. unable to set the visible property of the pivotitem class
    By goldfrapp01 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2013, 12:27 PM
  2. Unable to set the visible property of the PivotItem class
    By RagonichaFulva in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-29-2012, 02:51 AM
  3. Error 1004 unable to set the visible property of the pivotitem class
    By 4am in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-23-2012, 10:46 AM
  4. Error "Unable to set the Visible property of the PivotItem class"
    By Greg M in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-04-2010, 12:51 PM
  5. [SOLVED] Error:Unable to set the visible property of the PivotItem class.
    By Holger Pietsch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2005, 01:05 PM

Tags for this Thread

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