Hi,
Super VBA beginner here and need some basic help.
I am using VBA to create a pivot table and I need to calculate two values. I have successfully written the code to calculate the values but I need help to order the calculations into different columns because the code tries to overwrite the first calculation.
I need the pivot table to be structured like in the attached excel sheet.
Current code:
Sub Calculate_VAT()
With ActiveSheet.PivotTables("XXX Sales and VAT")
.CalculatedFields.Add "VAT", "='Enterprise XXX Vat Report Vat on 5pct'+'Enterprise XXX Vat Report Vat on 20pct'", True
.PivotFields("VAT").Orientation = xlDataField
End With
End Sub
Sub Calculate_ServiceFeeIncVAT()
With ActiveSheet.PivotTables("XXXX Sales and VAT")
.CalculatedFields.Add "Service Fee", "='Enterprise XXX Vat Report Service Fee Before Discount Ex Vat' + 'Enterprise XXX Vat Report Vat on Service Fee'", True
.PivotFields("Service Fee").Orientation = xlDataField
End With
End Sub
Bookmarks