I've created a Pivot Table, in a Macro. It isn't doing all of the Sum calculations on creation. When I refresh the Pivot Table manually, it looks like this:
The Pivot Table created in the Macro looks like this:
My code is:
'add, organize and format Pivot Table fields
The Pivot Table created in the Macro looks like this:
My code is:
'add, organize and format Pivot Table fields
VBA Code:
With myPivotTable
.PivotFields("Stands::StandTextName").Orientation = xlRowField
.PivotFields("GradingsSpecies").Orientation = xlRowField
With .PivotFields("TPA")
.Orientation = xlDataField
.Position = 1
.Function = xlSum
.NumberFormat = "#,##0.0000000"
End With
With .PivotFields("BASAL AREA")
.Orientation = xlDataField
.Position = 2
.Function = xlSum
.NumberFormat = "#,##0.00"
End With
'Turn off Grand Totals
myPivotTable.ColumnGrand = False
End With
'
'Refresh myPivotTable as a precaution
Range("B7").Select
ActiveSheet.PivotTables("PivotTableNewSheet").PivotCache.Refresh
Last edited by a moderator: