单击插入透视表按钮后运行下面的宏,可将当前透视表中第2至最后一个字段均添加到值,汇总方式为求和.
Sub test()
With ActiveSheet.PivotTables(1)
For i = 2 To .PivotFields.Count
Set f = .PivotFields(i)
.AddDataField f, "求和项:" & f.Name, xlSum
Next
End With
End Sub
Sub test()
With ActiveSheet.PivotTables(1)
For i = 2 To .PivotFields.Count
Set f = .PivotFields(i)
.AddDataField f, "求和项:" & f.Name, xlSum
Next
End With
End Sub
