I used the record feature to pick two categories "Sum of vol_gross" and "Sum of vol_net" and put those in the Data field. After the table was created I dragged them both to the Totals area so that it reflected the correct values. For a while the vol_gross was in column J and vol_net in column K, then for some random reason they switched. Any help with keeping vol_gross in column J and vol_net in column K would be really appreciated!!
This is the code I have so far:
With ActiveSheet.PivotTables("PivotTable3").PivotFields("vol_gross")
.Orientation = xlDataField
.Caption = "Sum of vol_gross"
.Position = 1
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields("vol_net")
.Orientation = xlDataField
.Caption = "Sum of vol_net"
.Position = 1
.Function = xlSum
End With
Range("K3").Select
With ActiveSheet.PivotTables("PivotTable3").DataPivotField
.Orientation = xlColumnField
.Position = 1
This is the code I have so far:
With ActiveSheet.PivotTables("PivotTable3").PivotFields("vol_gross")
.Orientation = xlDataField
.Caption = "Sum of vol_gross"
.Position = 1
.Function = xlSum
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields("vol_net")
.Orientation = xlDataField
.Caption = "Sum of vol_net"
.Position = 1
.Function = xlSum
End With
Range("K3").Select
With ActiveSheet.PivotTables("PivotTable3").DataPivotField
.Orientation = xlColumnField
.Position = 1