Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Pulling Data From PivotTable

I am writing a macro to extract data from a PivotField which is part
of my PivotTable (included) and the corresponding data from a
PivotField which is only in the PivotTable Field list (non-included).
I have not been able to get the data points from the two fields to
match up as I have only been able to get the data from the second (non-
included) field in alphabetical order.

The data as I need it would look like this....

Included field: Apple, Banana, Pear
Non-included field: Red, Yellow, Green

..... but what I'm getting is this.....

Included field: Apple, Banana, Pear
Non-included field: Green, Red, Yellow

The problem is further complicated when I am pulling only visible
items from the PivotTable, (i.e. Apple and Pear when Banana is hidden)
where non-included items do not distinguish between visible and
hidden.

The data is in an external data source (a database) and so am looking
to pull it in though the PivotTable.

Below is my macro that pulls the data back incorrectly.

Set pTbl = ThisWorkbook.Sheets(1).PivotTables(1)
rw = 0
For Each frt In pTbl.PivotFields("Fruit").PivotItems
rw = rw + 1
With Sheets("Sheet2")
..Cells(rw, 1).Value = frt.Name
..Cells(rw, 2).Value = pTbl.PivotFields("Color").PivotItems(rw).Name
End With
Next

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Pulling Data From PivotTable

Several things come to mind...

Is there a reason you are not putting the color field as a pivot row too?

There is not correlation between the order of the items in separate pivot
fields. If you have sorting turned on for a field then the items will be in
sorted order reguardless of where they appear in the data.

Since you are just indexing through the fruit pivot item and not checking
the value of hidden you are processing it even if it isn't displayed.

I would add color to the pivot table and then index through the cells on the
sheet rather than the items in the pivot field.

Peter

"DtTall" wrote:

I am writing a macro to extract data from a PivotField which is part
of my PivotTable (included) and the corresponding data from a
PivotField which is only in the PivotTable Field list (non-included).
I have not been able to get the data points from the two fields to
match up as I have only been able to get the data from the second (non-
included) field in alphabetical order.

The data as I need it would look like this....

Included field: Apple, Banana, Pear
Non-included field: Red, Yellow, Green

..... but what I'm getting is this.....

Included field: Apple, Banana, Pear
Non-included field: Green, Red, Yellow

The problem is further complicated when I am pulling only visible
items from the PivotTable, (i.e. Apple and Pear when Banana is hidden)
where non-included items do not distinguish between visible and
hidden.

The data is in an external data source (a database) and so am looking
to pull it in though the PivotTable.

Below is my macro that pulls the data back incorrectly.

Set pTbl = ThisWorkbook.Sheets(1).PivotTables(1)
rw = 0
For Each frt In pTbl.PivotFields("Fruit").PivotItems
rw = rw + 1
With Sheets("Sheet2")
..Cells(rw, 1).Value = frt.Name
..Cells(rw, 2).Value = pTbl.PivotFields("Color").PivotItems(rw).Name
End With
Next


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
Pulling data from other wb based on data to populate dropdown list Suzann Excel Discussion (Misc queries) 0 April 23rd 09 04:29 PM
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
Tying to extract all data from a pivot pulling from external data Ted Urban Excel Discussion (Misc queries) 3 September 14th 07 10:50 AM
Linking two spreadsheet, pulling data from one cell to another, data is being truncated Ben Excel Worksheet Functions 0 September 13th 07 11:41 PM
Saving worksheet as CSV after pulling data from an external data source Richard Edwards[_3_] Excel Programming 4 February 25th 05 09:08 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"