简体   繁体   English

从 VBA 中的 pivot 表字段列表中删除 pivot 字段

[英]deleting pivot field from pivot table field list in VBA

Is it possible to delete pivot field from pivot table field list in VBA code?是否可以从 VBA 代码中的 pivot 表字段列表中删除 pivot 字段?

I am using Excel 2007.我正在使用 Excel 2007。

I haven't worked for a long time with Excel + VBA, but have you tried something like:我已经很久没有使用 Excel + VBA 了,但是你有没有尝试过类似的东西:

Dim pvtField As Excel.PivotField
Dim pvtItem As Excel.PivotItem
For Each pvtField In pvtTable.PivotFields 
    For Each pvtItem In pvtField.PivotItems 
        pvtItem.Delete 
    Next 
Next 

This code should work to delete a field from the pivot table.此代码应该可以从 pivot 表中删除一个字段。

    ActiveSheet.PivotTables("Name of Table").PivotFields( _
    "Name of Field").Orientation = xlHidden

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM