Results 1 to 2 of 2

Run-time Error '1004':

Threaded View

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    Philadelphia
    MS-Off Ver
    Excel 2007
    Posts
    1

    Run-time Error '1004':

    Here is the situation
    I have a pivot table(PivotTabe1) on Worksheet "Graphs", whose purpose is to supply filter Line of Business Filter and control two Pivot Tables (PivotTable2 & PivotTable3) on Worksheet "Data"
    When I try and change the Line of Business Filter on the the Graph page I get a "Run-time error '1004': Unable to set the Visible property of the PivotItem class.
    The code is below- any help is appreciated it.


    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim IndexCtr As Double
    
    If Not Intersect(Target, Range("B1")) Is Nothing Then
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        
            With Worksheets("Data").PivotTables("PivotTable2").PivotFields("Line of Business")
                For IndexCtr = 1 To .PivotItems.Count
                    .PivotItems(IndexCtr).Visible = True
                Next IndexCtr
            End With
            
            With Worksheets("Data").PivotTables("PivotTable3").PivotFields("Line of Business")
                For IndexCtr = 1 To .PivotItems.Count
                    .PivotItems(IndexCtr).Visible = True
                Next IndexCtr
            End With
            With ActiveSheet.PivotTables("PivotTable1").PivotFields("Line of Business")
                For IndexCtr = 1 To .PivotItems.Count
                    Worksheets("Data").PivotTables("PivotTable2").PivotFields("Line of Business").PivotItems(IndexCtr).Visible = _
                    .PivotItems(IndexCtr).Visible
                    Worksheets("Data").PivotTables("PivotTable3").PivotFields("Line of Business").PivotItems(IndexCtr).Visible = _
                    .PivotItems(IndexCtr).Visible
                Next IndexCtr
            End With
           
        End If
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End Sub
    Last edited by Cutter; 08-01-2012 at 02:07 PM. Reason: Added code tags

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