Adding Calculated Fields in a PivotTable Report Using VBA

By Hemanta Sundaray on 2022-04-14

The following example adds a calculated field named Total Discount to the first PivotTable report on the active worksheet:

ActiveSheet.PivotTables(1).CalculatedFields.Add "Total Discount", _
        "=Discount + 'Promo Amount'", True

Note that the parameters Name & Formula (of data type String) are required.

Join the Newsletter