我正在试图弄清楚如何刷新数据透视表。当它到达pt.RefreshTable
并且我尝试了.RefreshTable
和.PivotCache.Refresh
时收到错误消息,他们都给了我错误代码1004.
Sub RefreshAllPivotTables()
Dim pt As PivotTable
activateSheet ("Sheet2")
Set pt = ActiveSheet.PivotTables("PivotTable3")
pt.RefreshTable
End Sub
Sub activateSheet(sheetname As String)
Worksheets("Sheet2").Activate
End Sub
答案 0 :(得分:2)
问题的解决方案是使用.Update
代替.RefreshTable
Sub RefreshAllPivotTables()
Dim pt As PivotTable
activateSheet ("Sheet2")
Set pt = ActiveSheet.PivotTables("PivotTable3")
pt.Update
End Sub