|
Show
All Items -- Excel 97/Excel 2000
In previous versions of Excel, where there is no Show All
checkbox, you can use programming to show or hide multiple fields. The
following code will show all items in all row fields.
To show column fields, change pt.RowFields to pt.ColumnFields.
To show all fields, change pt.RowFields to pt.VisibleFields.

Sub PivotShowItemAllVisible()
'sort is set to Manual to prevent errors, e.g.
'unable to set Visible Property of PivotItem class
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
For Each pt In ActiveSheet.PivotTables
For Each pf In pt.RowFields
pf.AutoSort xlManual, pf.SourceName
For Each pi In pf.PivotItems
pi.Visible = True
Next pi
pf.AutoSort xlAscending, pf.SourceName
Next pf
Next pt
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Hide
Items -- Excel 97/Excel 2000
In previous versions of Excel, where there is no Show All
checkbox, you can use programming to show or hide multiple fields. The
following code hides all items, except the last item, in all row fields.
To hide column fields, change pt.RowFields to pt.ColumnFields.
Sub HidePivotItemsVisible()
'hide all pivot items in all tables on sheet
'except last item
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
For Each pt In ActiveSheet.PivotTables
For Each pf In pt.RowFields
pf.AutoSort xlManual, pf.SourceName
For Each pi In pf.PivotItems
pi.Visible = False
Next
Next
pf.AutoSort xlAscending, pf.SourceName
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
|