Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default A Fix - Pivottable - Added calculated fields and now can't clear pivot

Hi - I had a problem with my code (see prev posting this morning
"Pivottable - Added calculated fields and now can't clear pivot")

The problem being that I could not set all elements of the pivot to
xlHidden when one of the elements was a calculated field.

I did a lot of searching to try and find a solution, but most of what
I found was other people with the same problem.

A colleague came up with the following idea:

Add a dummy element to the data area of the pivot and then actual make
the pivot data element itself invisible.

It seems for this to work there needs to be at least 2 dimensions/vars
in the pivot data area.

This is the code that (for the moment!) works:

Sub Macro2()
' Adds in a dummy field to the xldatafield of the pivot table
' then the entire data item can be hidden - doesn't seem to work
without
' doing it this way
Sheets("pivot").PivotTables(1).PivotFields("dummy" ).Orientation =
xlDataField
Sheets("pivot").PivotTables(1).PivotFields("dummy" ).Orientation =
xlDataField

Sheets("pivot").PivotTables("PivotTable1").PivotFi elds("data").Orientation
= xlHidden

' Then just hide any elements which are hidden
Set PT = Sheets("pivot").PivotTables(1)

With PT
For Each pf In .VisibleFields
pf.Orientation = xlHidden
Next
End With

End Sub

While this may be a fudge of sorts:

a) It works
b) Neither of us could see, or find any information as to why
calculated fields couldn't be hidden.

Hope this helps someone.

Andrew

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
2003 PIvotTable Calculated Fields Kay Excel Discussion (Misc queries) 3 April 24th 10 06:41 PM
Problem inserting calculated pivot fields into Pivot Table (2007) wamiller36 Excel Discussion (Misc queries) 1 March 5th 10 11:40 PM
Pivottable - Added calculated fields and now can't clear pivot Andreww Excel Programming 0 May 31st 07 05:10 PM
pivottable calculated fields HelpAl Excel Discussion (Misc queries) 3 December 8th 05 10:18 PM
Excel 2002 -> Problem with calculated fields in Pivottable H. Riewert Excel Discussion (Misc queries) 0 December 7th 04 09:33 AM


All times are GMT +1. The time now is 08:38 PM.

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

About Us

"It's about Microsoft Excel"