Solved

Excel: Loading pivotcache data into vba array

Posted on 2010-11-25
3
1,107 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

947 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now