Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
2003 PIvotTable Calculated Fields | Excel Discussion (Misc queries) | |||
Problem inserting calculated pivot fields into Pivot Table (2007) | Excel Discussion (Misc queries) | |||
Calculated Fields in Pivot | Excel Discussion (Misc queries) | |||
pivottable calculated fields | Excel Discussion (Misc queries) | |||
Excel 2002 -> Problem with calculated fields in Pivottable | Excel Discussion (Misc queries) |