I have a 'Run-time-error 1004 - Unable to set the Visible property of the PivotItems class' after running below code. It stuck from ".Visible = False"? Anyone can help to solve the problem?


Dim PT As PivotTable
Dim i As Integer
Set PT = ActiveSheet.PivotTables(1)

With PT.PivotFields("Trx_Date3")
.EnableMultiplePageItems = True

For i = 1 To .PivotItems.Count
With .PivotItems(i)
Select Case .Name

Case "dtend"
.Visible = True
Case Else
.Visible = False
End Select
End With
Next i
End With