How can I add calculated field in a pivot table at run time? Is it possible to use the sub-total field in the calculated field formula?
How can I add calculated field in a pivot table at run time? Is it possible to use the sub-total field in the calculated field formula?
You would use something like:
[VBA]
Worksheets(1).PivotTables(1).CalculatedFields.Add "PxS", _ "= Product * Sales"[/VBA]
Calculated fields work at an aggregate level.
Regards,
Rory
Microsoft MVP - Excel
Thanks rory. This helps.