Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PivotTable: ChildItems and ParentItem don't work

Hi

I'm programming creation and formatting of Excel pivot-tables, using
an Excel datasource.
I have three dimensions as Row fields in the pivot table. The top
dimension (ClientType) has two members: Segregated and Non-Seg. I'd
like to hide the third level of detail for all items (Clients) which
are children of the Segregated top-level member. I thought this code
would do the trick:

Dim objClient As Excel.PivotItem
For Each objClient In
Worksheets("Value").PivotTables("PTValue").PivotFi elds("ClientType").PivotItems("Seg").ChildItems
objClient.HideDetail
Next objClient

This runs without error, but doesn't do anything! If I break in this
procedure it's obvious why nothing is happening - I ask

? Worksheets("Value").PivotTables("PTValue").PivotFi elds("ClientType").PivotItems("Seg").ChildItems.Co unt

in the Immediate window, and get 0. Excel thinks there are no
ChildItems, when clearly there are (3 of them).
I thought I'd try to use the second-level (Client)'s ParentItem
property instead - iterate through all Clients, and if the ParentItem
is "Seg", then do a HideDetail. Here's the code:

Dim objClient As Excel.PivotItem
For Each objClient In
Worksheets("Value").PivotTables("PTValue").PivotFi elds("Policy").PivotItems
- If objClient.ParentItem.Name = "Seg" Then objClient.ShowDetails
= False
Next objClient

But the line marked - gives an error: 1004 "Unable to get the
ParentItem property of the PivotItem class". I check objClient's Name
in the Immediate window to check I've got the PivotItem I think I
should - I look at the pivottable, and that item clearly DOES have a
ParentItem.

There's no documentation of this problem anywhere (Microsoft or
Google). What is going on? I suspect that the ChildItems and
ParentItem properties simply don't work, but since few people use them
no-one's documented it.

Anyone got any ideas? Thanks!




Seb Thirlway
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
Cannot copy PivotTable to Network, at work. PedroDC Excel Discussion (Misc queries) 0 February 22nd 07 01:02 PM
I inserted a field =Amount1 - amount2 -PivotTable-doesn't work mark ivanowski Excel Discussion (Misc queries) 0 March 21st 06 07:40 PM
PivotTable - PivotTable Field name is not valid - error! miker1999[_17_] Excel Programming 1 June 10th 04 10:30 AM
Creating a PivotTable Report from an Another PivotTable Report bcpaulus Excel Programming 1 January 8th 04 07:56 PM


All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"