Solved

Excel: Loading pivotcache data into vba array

Posted on 2010-11-25
3
1,132 Views
Last Modified: 2012-05-10
Hi,
I would like to load the data from an existing pivot cache directly into an array using vba code.  I would be very grateful for any help.

Thanks in advance!
Gary
0
Comment
Question by:GaryAA
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 34212957
Unless the pivotcache is created from an ADO recordset, you can't do that - you'll have to extract the data from its original source.
0
 

Author Comment

by:GaryAA
ID: 34225593
Thanks for your answer, from my rsearch that appears to be true.  With that in mind, how about loading an array directly from the pivot table itself using vba code in a very automated manner.  I know how to load a range into an array as follows:

Dim LoadArray1 As Variant
LoadArray1 = Range("datarange")

Is there anything similar to the range concept except with a pivot table?
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 34225655
You can load from the table since it occupies a range, but all you will get is whatever is displayed in the table, not the underlying records. If that's what you want then you use the same method you mentioned with whichever range you are after - the TableRange1, TableRange2, DataBodyRange and so on. For example:

LoadArray1 = Activesheet.PivotTables(1).DataBodyRange.Value
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question