I have a button that uses simple VBA to refresh pivot tables.
When I click it I am getting:
Run-time error '1004':
Reference isn't valid.
When I select Debug
the following is highlighted:
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.
Updated the name and it worked again.
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.