Solved

Excel: Loading pivotcache data into vba array

Posted on 2010-11-25
3
1,238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

622 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