简体   繁体   English

vba 数据透视表 Excel 2016

[英]vba pivot table Excel 2016

Did the vba syntax for pivot table change, in Excel 2016?在 Excel 2016 中,数据透视表的 vba 语法是否发生了变化? This line, first in a block that creates a pivot table, was working under Excel 2010, but does not work now, under Excel 2016/ Windows 10:这一行,首先在创建数据透视表的块中,在 Excel 2010 下工作,但现在在 Excel 2016/Windows 10 下不起作用:

ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "Sheet1!R1C1:R" & lnglastrow & "C" & lnglastcol & "", Version:=xlPivotTableVersion14).CreatePivotTable _
        TableDestination:="Sheet4!R3C1", TableName:="PivotTable1", DefaultVersion _
        :=xlPivotTableVersion14

Typically it works if you split up that line into two steps通常,如果您将该行分成两个步骤,它会起作用

Dim pc as pivotcache, pt as pivottable

Set pc = ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, _
          SourceData:= "Sheet1!R1C1:R" & lnglastrow & "C" & lnglastcol, _ 
          Version:=xlPivotTableVersion14)

Set pt = pc.CreatePivotTable(TableDestination:="Sheet4!R3C1", TableName:="PivotTable1", _
                               DefaultVersion :=xlPivotTableVersion14

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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