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

I have some code that modifies a pivot (changes dimensions and
measures)

It all worked well until I wrote some VB to calculate some new cols/
measures. They appear as they should in the field list so I know that
the code to add them works:

Sub add_to_pivot()
With Sheets("pivot").PivotTables(1)
.CalculatedFields.Add Name:="cust_spend", Formula:="=spend/
Count"
.CalculatedFields.Add Name:="cust_vis", Formula:="=vis/Count"
.CalculatedFields.Add Name:="cust_duration",
Formula:="=duration/Count"
End With
End Sub


When I try to run the code that manipulates the pivot I get "runtime
error 1004" "unable to set the orientation property of the pivotfield
class".

The Code that fails is as follows:

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

My understanding is that the above code removes all dims/measures from
the pivottable, which it does fine unless one of the calculated
measures is inlcuded in the code run.

Do I have to do anything to these calculated fields to get them
recognised in some way??

I noticed various references to "PT.ManualUpdate = true"... put this
in my code and the whole thing froze up.

Cheers

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
Calculated Fields in Pivot xlcharlie Excel Discussion (Misc queries) 0 January 25th 06 09:01 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 01:32 AM.

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"