LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.scripting.vbscript
external usenet poster
 
Posts: 26
Default How to replace PivotTable data fields...?

Hi,

I'm progamming a pivot table using VBA. I have no problem manipulating
column or row fields, but how can I replace a data field? Everything I try
just adds the data field to the existing data field resulting in a mess.

The PivotTable.addfields methods *replaces* whatever columns were previously
designated as RowFields, ColumnFields, and PageFields with the new
specifications, as in:

..AddFields RowFields:="Date", PageFields:="Location"
But no matter what I try, I can't replace the data field.... I've even tried
setting the Orientation property to xlHidden, as follows:

' Hide existing data fields
For each pf In .DataFields
Debug.Print "deleting pf", pf.Name
pf.Orientation = xlHidden
'pf.Delete ' I tried deleting too
Next

They key is that I need to do this via code. I can easily do it by using the
Excel GUI. I recorded the resulting code - Excel was hidding the field by
setting its Orientation property to xlHidden. Why doesn't that work for me?

Many thanks in advance,

Robert Stober


 
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
Linking PivotTable Fields - Excel 2007 Jim Excel Discussion (Misc queries) 1 August 6th 09 09:57 PM
Pivottable Sum of fields. Saviz Excel Discussion (Misc queries) 1 July 17th 08 12:10 PM
pivottable calculated fields HelpAl Excel Discussion (Misc queries) 3 December 8th 05 10:18 PM
PivotTable - Unchecking and re-checking data fields Jeff K Excel Discussion (Misc queries) 1 July 20th 05 09:36 PM


All times are GMT +1. The time now is 09:57 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"