Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to use Index? | Excel Discussion (Misc queries) | |||
Chart axes color index vs font color index | Charts and Charting in Excel | |||
How do I pull the col. index value as well as row index value | Excel Discussion (Misc queries) | |||
PivotTable ColumnFields AutoSelection | Excel Programming | |||
pivotcell | Excel Programming |