2015-11-25 190 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程序員。 –

相關問題