View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Stoney Stoney is offline
external usenet poster
 
Posts: 1
Default PivotTable columns not going Invisible

I have a pivot table in Excel 2000 based on an OLAP cube.
There is one field on the column of the PT
called "StoreName". There are 20 StoreNames on the cube
but I want only 5 to appear on the PT.

When I build this PT, all 20 come over from the cube. I
was anticipating that the visible property of the
PivotItem object might allow me to see only the StoreNames
I want by setting the others invisible with something like
this:

'pt is the pivot table
Dim pf as PivotField
Dim pi as PivotItem
For Each pf In pt.VisibleFields
If pf.Orientation = xlColumnField Then
For Each pi In pf.PivotItems
If Left(pi.name,1) = "N" Then
pi.Visible = False
End If
Next
End If
Next

I get "Run-time error 1004. Application-defined or object-
defined error" as this line: pi.Visible = False.

This works if the PT source is something besides a cube.
I'm hoping you might know how to do this for a cube.

Thanks,
Stoney