我会注释你的代码为你,如果这有助于:
'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 –