有人可以解释我这个VBA代码是什么意思?

这是macros的一个优秀的。 我真的迷失在这里。 我真的很感激任何帮助。

Sheets("5. Resume").Select ActiveSheet.PivotTables("PivotTable1").PivotSelect "'Tarea IS'[All]", _ xlLabelOnly, True ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh ActiveSheet.PivotTables("PivotTable2").PivotSelect "'Tarea IS'[All]", _ xlLabelOnly, True ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh Sheets("6. Reg Err").Select ActiveSheet.PivotTables("PivotTable3").PivotCache.Refresh 

如果有帮助,我会为你评论你的代码:

 '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 

你selectpivottable的行似乎是无关的,因为你正在改变select后不做任何事情,当前选定的项目(我猜这是logging)。 您可以使用.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