View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default [VBA] Hiding rows in PivotTable

multiposted


--
Don Guillett
SalesAid Software

"xpan" wrote in message
...
Hi,

I have PivotTable in Excel 2003. In "Row Fields" there is dimension called
[DepartmentEmployee] which consists of [Department] and [Employee] levels.
To hide rows I used the following code:
Sub Hide()
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Set pt = ActiveSheet.PivotTables(1)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
For Each pf In pt.RowFields
For Each pi In pf.PivotItems
pi.Visible = False
Next pi
Next pf
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

The problem is, that when the code is done there is no change in the
layout
of PivotTable.What went wrong?

In this code "for" loops are iterated for Departments and Employees that
are
shown in the current layout of PivotTable.
What should I do to make "for" loops iterate for all Departments and
Employees (even the hidden ones).

Thanks for any help.
--
TM