Did the vba syntax for pivot table change, in Excel 2016? 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:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.