使用VBA代码,我创建了一个Pivot表,然后添加了行,列和值。现在我需要添加过滤器。 你能否告诉我如何添加过滤器?
我有一个VBA代码,需要使用过滤器循环数据透视表。 到目前为止:
'Add item to the Report Filter- chose the filter that you want
pvt.PivotFields("DB").Orientation = xlPageField
'Position Item in list
pvt.PivotFields("DB").Position = 1
非常感谢任何帮助!
答案 0 :(得分:0)
以下是如何将过滤器添加到我知道的数据透视表中。
Dim pvt As PivotTable
Set pvt = ActiveSheet.PivotTables("PivotTable1")
'Adds to the Report Filter
pvt.PivotFields("DB").Orientation = xlPageField
'Adds to the Column Labels
pvt.PivotFields("DB").Orientation = xlColumnField
'Adds to the Row Labels
pvt.PivotFields("DB").Orientation = xlRowField