简体   繁体   中英

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?

I am using Excel 2007.

I haven't worked for a long time with Excel + VBA, but have you tried something like:

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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