Results 1 to 3 of 3

Code error “wrong number of arguments or invalid property assignment”

Threaded View

  1. #1
    Registered User
    Join Date
    04-28-2011
    Location
    Auckland
    MS-Off Ver
    Excel 2003
    Posts
    24

    Code error “wrong number of arguments or invalid property assignment”

    What is wrong with this bit of code?

    Sub ShowAllItemsks()
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    Dim objPT As PivotTable
    Dim objPTField As PivotField
    Dim objPTItem As PivotItem
     
    For Each ws In Worksheets
    ws.Visible = xlSheetVisible
        For Each objPT In ws.PivotTables
     MsgBox "Pivot table name: " & objPT.Name & vbCrLf & "Sheet name: " & ws.Name & vbCrLf & "test"
        With objPT
                    
                    ' Run through all the column fields
            For Each objPTField In .ColumnFields
                        '
                        ' Get the hidden items and make them visible
                        For Each objPTItem In objPTField
                        
                        objPTItem("A").Visible = True
                        objPTItem("B").Visible = False
                        Next 'objPTItem
            Next 'objPTField
        End With
    Application.ScreenUpdating = True
     
        Next objPT
    Next ws
    End Sub
    It points at an error in this line of code with error “wrong number of arguments or invalid property assignment”

    objPTItem("A").Visible = True
    Appreciate any help. Example attached.
    Attached Files Attached Files

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