Hi All,
In the attached file there is a pivot table, wherein I want to toggle between expand entirefields and collapse entire field(pivot field client) with the help of macro. In other words if a user clicks the button, pivot field(client) should expand all and if he/she clicks again it should collapse all the fields.
I tried with below code which didn't work. Can any one help me please?
Many thanks.
Rudra
In the attached file there is a pivot table, wherein I want to toggle between expand entirefields and collapse entire field(pivot field client) with the help of macro. In other words if a user clicks the button, pivot field(client) should expand all and if he/she clicks again it should collapse all the fields.
I tried with below code which didn't work. Can any one help me please?
Many thanks.
Rudra
Code:
Option Explicit
Sub ExpandCollapse()
Dim PT As PivotTable
Set PT = Sheets("Pivot").PivotTables(1)
If PT.PivotFields("Client").ShowDetail = False Then
PT.PivotFields("Client").ShowDetail = True
End If
End Sub