[英]Excel Reference isn't valid for PivotTables RefreshTable
I have a button that uses simple VBA to refresh pivot tables. 我有一个使用简单的VBA刷新数据透视表的按钮。
When I click it I am getting: 当我单击它时,我得到:
Run-time error '1004': 运行时错误“ 1004”:
Reference isn't valid. 引用无效。
When I select Debug
the following is highlighted: 当我选择“ Debug
,将突出显示以下内容:
pt.RefreshTable pt.RefreshTable
Full code: 完整代码:
Sub Refresh_pivot()
Sheets("Control").Select
Application.ScreenUpdating = False
Dim pt As PivotTable
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws
Application.ScreenUpdating = True
Application.Goto Reference:="returncell"
Range("A15").Select
End Sub
Can anyone help explain the problem I have encountered? 谁能帮助解释我遇到的问题?
The issue was a pivot table referencing an ODBC data dump which had changed its external table name. 问题是透视表引用了已更改其外部表名称的ODBC数据转储。
Updated the name and it worked again. 更新了名称,它再次起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.