我會註釋你的代碼爲你,如果這有助於:
'Select the sheet named "5. Resume"
Sheets("5. Resume").Select
'Select the pivot table named "PivotTable1" on the active sheet ("5. Resume")
ActiveSheet.PivotTables("PivotTable1").PivotSelect "'Tarea IS'[All]", _
xlLabelOnly, True
'Refresh the data in "PivotTable1" on the selected sheet ("5. Resume") from the source
ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
'Select the pivot table named "PivotTable2" on the active sheet ("5. Resume")
ActiveSheet.PivotTables("PivotTable2").PivotSelect "'Tarea IS'[All]", _
xlLabelOnly, True
'Refresh the data in "PivotTable1" on the selected sheet ("5. Resume") from the source
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
'Select the sheet named "6. Reg Err"
Sheets("6. Reg Err").Select
'Refresh the data in "PivotTable3" on the selected sheet ("6. Reg Err") from the source
ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh
,你選擇數據透視表的線條似乎是無關緊要你不久後改變選擇而不做任何的目前選定的項目(我猜這是記錄)。你可以刪除.PivotSelect
的行,它不會改變結果。
ActiveSheet.PivotTables("PivotTable1").PivotSelect "'Tarea IS'[All]", _
xlLabelOnly, True
事實上,下面的代碼獲得相同的在更短的時尚:
With Sheets("5. Resume")
.PivotTables("PivotTable1").PivotCache.Refresh
.PivotTables("PivotTable2").PivotCache.Refresh
End With
Sheets("6. Reg Err").PivotTables("PivotTable3").PivotCache.Refresh
簡單的谷歌搜索'透視表練成vba'會給你足夠的結果。這[link](http://www.thespreadsheetguru.com/blog/2014/9/27/vba-guide-excel-pivot-tables)會給你一個啓動。 – ManishChristian
這是刷新數據透視表結果。 –
「Refresh」es數據透視表,Pivottable1和Pivottable2 –