Sub SetupPivot()
Dim nPT As PivotTable Set nPT = ActiveSheet.PivotTables("PT001") nPT.RefreshTable End SubATUALIZANDO TODAS AS TABELAS DINÂMICAS NUMA WOKSHEET (Refresh all Pivot Tables in a Worksheet):
Sub SetupAllPivotsWorksheet()
Dim nPT As PivotTable For Each nPT In ActiveSheet.PivotTables nPT.RefreshTable Next nPT End Sub
ATUALIZANDO TODAS AS TABELAS DINÂMICAS PRÉ-SELCIONADAS NUMA WOKSHEET (Refresh Chosen Pivot Tables in a Worksheet):Sub AllChosenPivotswSheet() Dim nPT As PivotTable
For Each nPT In ActiveSheet.PivotTables Select Case nPT.Name Case "PT001", "PT005", "PT009" nPT.RefreshTable Case Else End Select Next pt End Sub
ATUALIZANDO TODAS AS TABELAS DINÂMICAS PRÉ-EXISTENTES NUM WORKBOOK (Refresh All Chosen Pivot Tables in a Workbook):
Sub AllChosenPivotswBook()
Dim nPT As PivotTable Dim nWS As Worksheet For Each nWS In ActiveWorkbook.Worksheets For Each nPT In nWS.PivotTables nPT.RefreshTable Next nPT Next nWS End SubATUALIZANDO TODAS AS QUERYTABLES PRÉ-EXISTENTES NUM WORKBOOK (Refresh All QueryTable instead):
Sub AllChosenPivotswBook()
Dim qryTbl As QueryTable Dim nWS As Worksheet For Each nWS In ActiveWorkbook.WorksheetsFor Each qryTbl In nWS.QueryTables
qryTbl.Refresh BackgroundQuery:=False
Next qryTbl
Next nWS End Sub
ATUALIZA TODAS AS TABELAS DINÂMICAS NUMA WOKSHEET QUANDO ESTA FOR ALTERADA (Automatically refresh pivot table when data in a sheet changes in Excel):
Baixe planilha para teste.
Private Sub Worksheet_Calculate()
Sheets("PT001").PivotTables("PivotTable001").RefreshTable
End Sub
Tags: VBA, Excel, Pivot, Table, Pivot Table, refresh, atualizar, tabela dinâmica