Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

Add calculated items to a field using the Add method of the CalculatedItems collection

Sub AddCalculatedItem()      With ActiveSheet.PivotTables(1).PivotFields("Product")          .CalculatedItems.Add Name:="Melons", Formula:="=Mangoes*1.5"      End With      End Sub