I have an EXCEL 2013 pivot table to which I am trying to datafields but I keep getting a runtime 9 error at the red text.
The data for the pivot table is a named range (AAA) that has been added to the datamodel.
I have simply recorded a macro and changed activesheet (ws15) & pivot table (uu) to my variables.
ws15.PivotTables(uu).CubeFields.GetMeasure "[AAA].[RID]", xlCount, "RID"
ws15.PivotTables(uu).AddDataField ws15.PivotTables(uu).CubeFields("[Measures].[Distinct Count of RID]"), "RID"
Also tried the code like this: where pvt1 = my pivot table
pvt1.CubeFields.GetMeasure "[AAA].[RID]", xlCount, "RID"
pvt1.AddDataField pvt1.CubeFields("[Measures].[Distinct Count of RID]"), "RID"
Anyone have a clue as to what the problem is?
Any assistance appreciated.
Thanks.
Bookmarks