GETPIVOTDATA Function
The GETPIVOTDATA function queries a pivot table and returns specific data based on the pivot table structure, instead of cell references. The main advantage of using this function is that it ensures that the correct data is returned, even if the pivot table layout is changed.
Refer the following code to use GETPIVOTDATA and IRange.GenerateGetPivotDataFunction().