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.
Bookmarks