Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 筛选特定值的透视表_Excel_Vba - Fatal编程技术网

Excel 筛选特定值的透视表

Excel 筛选特定值的透视表,excel,vba,Excel,Vba,我一直在尝试过滤使用宏创建的数据透视,我希望在创建表之前过滤表,以获得一个特定的帐号12789 以下是我用于创建pivot的代码: Set ws = ActiveSheet Set wb = ThisWorkbook Set pc = wb.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=Range("Bank[#All]"), _ Version:=xlPivotTableVersion15) Set pt

我一直在尝试过滤使用宏创建的数据透视,我希望在创建表之前过滤表,以获得一个特定的帐号12789

以下是我用于创建pivot的代码:

Set ws = ActiveSheet
Set wb = ThisWorkbook

Set pc = wb.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=Range("Bank[#All]"), _
Version:=xlPivotTableVersion15)

Set pt = ws.PivotTables.Add(PivotCache:=pc, TableDestination:=Range("AR2"), TableName:="Pivot")


With pt

.PivotFields("narrative_account_number").Orientation = xlRowField
.PivotFields("Debit amount").Orientation = xlDataField

End With
有关于如何过滤数据的见解吗

提前感谢

,带有数据透视字段(“叙述账户编号”)
.Orientation=xlRowField
对于.PivotItems中的每个项目
如果项目为“12789”,则项目可见=False
下一个
以
pt.PivotFields(“借方金额”).Orientation=xlDataField