Excel引用对于数据透视表RefreshTable无效
我有一个使用简单的VBA来刷新数据透视表的button。
当我点击它时,我得到:
运行时错误“1004”:
参考无效。
当我selectDebug
,突出显示以下内容:
pt.RefreshTable
完整代码:
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
任何人都可以帮助解释我遇到的问题?
问题是引用ODBC数据转储的数据透视表已经改变了它的外部表名。
更新了名称,它再次工作。