+ Reply to Thread
Results 1 to 2 of 2

Run-time Error '1004':

Hybrid View

jcmorella Run-time Error '1004': 08-01-2012, 11:55 AM
Cutter Re: Run-time Error '1004': 08-01-2012, 02:07 PM
  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

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Run-time Error '1004':

    @ jcmorella

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

+ 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