Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.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
在VBA中使用WITH刷新Excel 2016数据透视表失败?_Excel_Vba_Pivot Table_With Statement - Fatal编程技术网

在VBA中使用WITH刷新Excel 2016数据透视表失败?

在VBA中使用WITH刷新Excel 2016数据透视表失败?,excel,vba,pivot-table,with-statement,Excel,Vba,Pivot Table,With Statement,此代码适用于: Activesheet.PivotTables("PivotTable1").PivotCache.RefreshTable 此代码不支持,返回错误消息“对象不支持此属性或方法”: 为什么?PivotCache.RefreshTable看起来像是数据透视表的一种方法。这两个代码段完全相同,只是语法略有不同。PivotCache对象没有方法RefreshTable(但是,它有一个方法Refresh)-但这意味着两个代码段都会抛出相同的错误。值得注意的是,如果在

此代码适用于:

Activesheet.PivotTables("PivotTable1").PivotCache.RefreshTable
此代码不支持,返回错误消息“对象不支持此属性或方法”:


为什么?

PivotCache.RefreshTable
看起来像是数据透视表的一种方法。这两个代码段完全相同,只是语法略有不同。
PivotCache
对象没有方法
RefreshTable
(但是,它有一个方法
Refresh
)-但这意味着两个代码段都会抛出相同的错误。值得注意的是,如果在手动刷新数据透视表时使用XL“Record Macro”,则记录的VBA会包含数据透视缓存项。当我记录宏时,生成的代码是
.PivotCache.Refresh
,这是有效的
.PivotCache.RefreshTable
绝对不是。删除我的答案并投票以键入错误/不可复制的方式关闭。
With Activesheet
   .PivotTables("PivotTable1").PivotCache.RefreshTable
End With