计算字段未填充-数据透视Excel vba



谁能给一个简短的提示为什么计算。字段没有被创建?这两个总和出现了,但第三个没有。

'Insert Data Field
With ActiveSheet.PivotTables("ForwinPivotTable").PivotFields("Gross Profit (EUR)")
.Orientation = xlDataField
.Position = 1
.Function = xlSum
.NumberFormat = "#,##0"
.Name = "GP (Eur) "
End With
'Insert Data Field
With ActiveSheet.PivotTables("ForwinPivotTable").PivotFields("Export Chargeable Weight (kg)")
.Orientation = xlDataField
.Position = 1
.Function = xlSum
.NumberFormat = "#,##0"
.Name = "Total Charg. Weight "
End With
With ActiveSheet.PivotTables("ForwinPivotTable").CalculatedFields
.Add "GP/kg (Eur)", "= 'GP (Eur) '/ 'Total Charg. Weight '"
.PivotFields("GP/kg (Eur)").Orientation = xlDataField
End With
With ActiveSheet.PivotTables("ForwinPivotTable")
.CalculatedFields.Add "GP/kg (Eur)", "= 'Gross Profit (EUR)'/ 'Export Chargeable Weight (kg)'"
.PivotFields("GP/kg (Eur)").Orientation = xlDataField
End With

我犯的错误是引用字段不是通过源标题,而是通过数据透视表中的标题。

相关内容

  • 没有找到相关文章

最新更新