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

hattrick_123

New Member
Joined
Apr 5, 2011
Messages
7
What is wrong with this bit of code?<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
Code:
Sub ShowAllItemsks()<o:p></o:p>
Application.ScreenUpdating = False<o:p></o:p>
Dim ws As Worksheet<o:p></o:p>
Dim objPT As PivotTable<o:p></o:p>
Dim objPTField As PivotField<o:p></o:p>
Dim objPTItem As PivotItem<o:p></o:p>
 <o:p></o:p>
For Each ws In Worksheets<o:p></o:p>
ws.Visible = xlSheetVisible<o:p></o:p>
    For Each objPT In ws.PivotTables<o:p></o:p>
 MsgBox "Pivot table name: " & objPT.Name & vbCrLf & "Sheet name: " & ws.Name & vbCrLf & "test"<o:p></o:p>
    With objPT<o:p></o:p>
                <o:p></o:p>
                ' Run through all the column fields<o:p></o:p>
        For Each objPTField In .ColumnFields<o:p></o:p>
                    '<o:p></o:p>
                    ' Get the hidden items and make them visible<o:p></o:p>
                    For Each objPTItem In objPTField<o:p></o:p>
                    <o:p></o:p>
                    objPTItem("A").Visible = True<o:p></o:p>
                    objPTItem("B").Visible = False<o:p></o:p>
                    Next 'objPTItem<o:p></o:p>
        Next 'objPTField<o:p></o:p>
    End With<o:p></o:p>
Application.ScreenUpdating = True<o:p></o:p>
 <o:p></o:p>
    Next objPT<o:p></o:p>
Next ws<o:p></o:p>
End Sub<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
It points at an error in this line of code with error “wrong number of arguments or invalid property assignment”<o:p></o:p>
<o:p></o:p>
Code:
objPTItem("A").Visible = True<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
Appreciate any help.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,224,559
Messages
6,179,513
Members
452,921
Latest member
BBQKING

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top