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
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
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