未填充计算字段 - 数据透视表 Excel vba
Calculated Field not populating - Pivot Excel vba
有人可以给出一个简短的提示,为什么没有创建 calculated.field 吗?出现了两个总和,但没有出现第三个。
'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
我犯的错误是引用字段时不是按来源标题而是按数据透视表中的标题 table。
有人可以给出一个简短的提示,为什么没有创建 calculated.field 吗?出现了两个总和,但没有出现第三个。
'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
我犯的错误是引用字段时不是按来源标题而是按数据透视表中的标题 table。