Macro to pull a list of all PivotTable Fields from an OLAP CUBE

im2bz2p345

Board Regular
Joined
Mar 31, 2008
Messages
226
Hi all,

Is there a way to pull all PivotTables fields when connected to a OLAP cube?

I found this topic on OZGrid with a similar request: Listing Pivottable Field List Fields - OzGrid Free Excel/VBA Help Forum

Post#8 has the code which I need (copy-pasted below) but that post is from 2006 and every time that I try to run that code, it gives me a Run-time error '9' subscript out of range error on this line:
For Each objCubeFld In Worksheets("PivotTable Data").PivotTables(1).CubeFields

VBA Code:
Sub list_cube_fields()
 Set objNewSheet = Worksheets.Add
 objNewSheet.Activate
 intRow = 1
 For Each objCubeFld In Worksheets("PivotTable Data").PivotTables(1).CubeFields
 objNewSheet.Cells(intRow, 1).Value = objCubeFld.Name
 intRow = intRow + 1
 Next objCubeFld
 
End Sub

I don't know VBA too well, but I did try changing .PivotTables(1) to .PivotTables1 (since my PivotTable is named PivotTables1), but that didn't help.

Does anyone know what to change to get this code to work? For reference, I'm running the 32-bit MS Excel 365 MSO (16.0.13801.21050) version.

Ty in advance for any help on this,

~ im2bz2p345 :)
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,214,589
Messages
6,120,415
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top