ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   About the use of "Getpivotdata" (https://www.excelbanter.com/excel-programming/301892-about-use-getpivotdata.html)

Polly[_3_]

About the use of "Getpivotdata"
 
I have a pivot table in Excel and the data source is from
an OLAP cube. I want to use macro for data manipulation.
However, the process is dynamic.

For example, if column field is "Month" and row field
is "Region", then the statement for getting the sales of
Region A in March will be

GETPIVOTDATA("[Measures].
[Sales]",$A$4, "[Months]", "[Months].[March]",
"[Region]","[Region].[Region A]")

If column field is "Month" and row fields are "Region"
and "Product", then the statement for for getting the
Product A's sales of Region B in March will be

GETPIVOTDATA("[Measures].[Sales]",$A$4, "[Months]",
"[Months].[March]", "[Region]","[Region].[Region
B]","[Region]","[Product].[Product A]")

My main problem is that the number of fields in pivot
table is not known. I donno how to write
"getpivotdata" statement in a dynamic way. I hope
somebody can help me to solve this problem. Thanks!

Best Wishes,
Polly




All times are GMT +1. The time now is 03:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com