使用VBA过滤数据透视表中的前10名时出现错误1004

问题描述 投票:0回答:1

我已经设置了数据透视表,按日期进行过滤,并按销售额排序。现在,我尝试过滤前 10 个,但我不断收到 Error 1004:应用程序定义或对象定义的错误

'Ventas means Sales & Total Ventas means Total Sales.
 With .PivotFields("Ventas")
            .Orientation = xlDataField
            .Position = 1
            .Function = xlSum
            .NumberFormat = "#,##0"
            .Name = "Total Ventas"
        End With

ptTable.PivotFields("Total Ventas").AutoShow Type:=xlAutomatic, Range:=xlTop, Count=10, Field="Total Ventas"
excel vba
1个回答
0
投票

PivotFields 必须是一行,DataField 必须是一个值。

ptTable.PivotFields(“SKU”).PivotFilters.Add2 类型:=xlTopCount,DataField:=ptTable.PivotFields(“总 Ventas”),值 1:=10

© www.soinside.com 2019 - 2024. All rights reserved.