LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default PivotTable.columnfields(index) vs Pivotcell.columnitem(index)

I have a pivot table that looks like the following:
(Rowfields : Country, State
Columnfields: Company, Department)

Dell
Sales | Marketing
USA | CA 8 10
| FL 2 3

As I'm trying to automate the process of extracting data from this
table using GetPivotData method, I ran into a problem. I was puzzled
to find that PT.ColumnFields(1) returns "Department" not "Company,"
yet pcell.columnitems(1) returns "Dell", not "Sales." In other words,
columnitems use the index the items in the order they appear, but
columnfields do not. I think what's happening here is that
Columnfields index the items in the order added (to the pivottable),
regardless of its actual location it is placed relative to the other
column fields.
Apparently, this causes errors with GetPivotData because there is no
Department called Dell.

Set PT = Worksheets("test").PivotTables(1)
Set pcell = Activecell.PivotCell

PT.GetPivotData(pcell.DataField, PT.RowFields(1), pcell.RowItems(1), _
PT.RowFields(2),
pcell.RowItems(2), _
PT.ColumnFields(1),
pcell.ColumnItems(1), _
PT.ColumnFields(2),
pcell.ColumnItems(2))

With that said, is there a way to get the field name based on the
actual location?

Thanks for your help in advance.

 
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
How to use Index? Eric Excel Discussion (Misc queries) 1 October 5th 07 02:04 AM
Chart axes color index vs font color index [email protected] Charts and Charting in Excel 4 December 7th 06 04:05 PM
How do I pull the col. index value as well as row index value Vikram Dhemare Excel Discussion (Misc queries) 1 March 29th 06 07:48 AM
PivotTable ColumnFields AutoSelection Bob[_64_] Excel Programming 0 January 13th 05 01:50 AM
pivotcell Kellyc Excel Programming 0 December 1st 04 03:35 PM


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