我已经设置了数据透视表,按日期进行过滤,并按销售额排序。现在,我尝试过滤前 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"
PivotFields 必须是一行,DataField 必须是一个值。
ptTable.PivotFields(“SKU”).PivotFilters.Add2 类型:=xlTopCount,DataField:=ptTable.PivotFields(“总 Ventas”),值 1:=10