Hi,
Somewhere during the course you show some examples of using GETPIVOTDATA,
and making the parameters dynamic.
Now I need some VBA-function to fill an overview I cannot manage with a 'simple' PivotTable.
When I get the formula in a worksheet, it shows like:
=DRAAITABEL.OPHALEN("[Measures].[Som van Rooster]";$B$3;"[Sengineers].[Sengineer]";"[Sengineers].[Sengineer].&[Abdallah]";"[Capaciteit].[Jaar]";"[Capaciteit].[Jaar].&[2021]";"[Capaciteit].[Week]";"[Capaciteit].[Week].&[1]")
(long live the regional translations )
This is to get some SUM for a specific person (sengineer), year and week.
When I copy this string into a function (remove the pivottable reference, and replace ; with , for regional settings) it works !
But whatever changes I try for making it dynamic the value returned is just 0 in all cases.
Do you have a clue to do this?
(I used something like:
Set PS = Sheets("CapaciteitNw")
With PS
.Activate
Set PT = .PivotTables("DTCap")
On Error Resume Next
selSTr = "[Sengineers].[Sengineer]", "[Sengineers].[Sengineer].&[Abdallah]", "[Capaciteit].[Jaar]", "[Capaciteit].[Jaar].&[2021]", _
"[Capaciteit].[Week]", "[Capaciteit].[Week].&[14]").Value
rooster = PT.GetPivotData("[Measures].[Som van Rooster]" & ", " & selStr).Value
.....
Kind regards,
Maarten
Hi Maarten,
GETPIVOTDATA is covered in session 7.10 of the Power Pivot course. I would get the formula working in the spreadsheet before moving it to VBA.
VBA is outside the scope of this course, but if the above tutorial doesn't shed any light, please post your question in our VBA forum.
Thanks,
Mynda