Hello,
Please see my code below:
I'm trying to divide my traded volume by the market volume. I think the below code should do this, but some of the answers it produces are incorrect. Has anyone got any idea why this might be please?
Thanks
Jo
Please see my code below:
I'm trying to divide my traded volume by the market volume. I think the below code should do this, but some of the answers it produces are incorrect. Has anyone got any idea why this might be please?
Thanks
Jo
Code:
' Define Calculated Fields
PT.CalculatedFields.Add Name:="% of market vol", Formula:="=Executed Quantity/volume"
' Set up the data fields
With PT.PivotFields("Executed Quantity")
.Orientation = xlDataField
.Function = xlSum
.Position = 1
.Name = "Aspect Executed Volume"
.NumberFormat = "#,##0_ ;[Red]-#,##0 "
End With
With PT.PivotFields("volume")
.Orientation = xlDataField
.Function = xlAverage
.Position = 2
.Name = "Market Volume"
.NumberFormat = "#,##0_ ;[Red]-#,##0 "
End With
With PT.PivotFields("% of market vol")
.Orientation = xlDataField
.Function = xlSum
.Position = 3
.NumberFormat = "0.00%"
.Name = "Aspect % of Market Vol"