If anyone has the same problem please do the following:
Use the CreateCubeFile Method
Sub CreateCubeFile()
ActiveSheet.PivotTables(“PivotTable1”).CreateCubeFile File:=”C:\CustomCubeFile.cub”
End Sub
- The benefit of using this method is that the data in the offline cube file will consist of the exact data that existed in the pivot table at the time you executed the procedure.
- For example, if your pivot table contains a page field that is filtered to show data for only the United States, then the offline cube that is created by the CreateCubeFile method will contain data only for the United States.
- This is because the CreateCubeFile method essentially runs the MDX query behind the pivot table and outputs the results to a local .cub file.
- So if you have the need to create several offline cubes, each containing a different set of data, you can simply automate the rearranging of the data fields with the pivot table and then employ the CreatCubeFile method.
The source of this data is:Link