2015-11-25 188 views
0

这是为了与宏的excel。我真的迷失在这里。我非常感谢任何帮助。有人可以解释我这个VBA代码的含义吗?

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 
+0

简单的谷歌搜索'透视表练成vba'会给你足够的结果。这[link](http://www.thespreadsheetguru.com/blog/2014/9/27/vba-guide-excel-pivot-tables)会给你一个启动。 – ManishChristian

+0

这是刷新数据透视表结果。 –

+0

“Refresh”es数据透视表,Pivottable1和Pivottable2 –

回答

2

我会注释你的代码为你,如果这有助于:

'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 
+0

谢谢你和所有其他有用的评论者。如果我的问题太具体,我很抱歉,我不是VBA程序员。 –

相关问题