Refresh Pivot Table using VBA in Excel - ScoreInExcel

Easy way to Learn Excel....

ads
Responsive Ads Here

Post Top Ad

Your Ad Spot

Tuesday 22 August 2017

Refresh Pivot Table using VBA in Excel

Untitled Document In Excel, you can refresh a pivot table automatically using macro code. There are multiple way to refresh the excel pivot table. We will see one by one to execute in excel workbook.
To refresh multiple pivot table in excel workbook. follow the below methods to execute automatically. Copy the any one of the below code and paste it in your excel workbook where it required to refresh the pivot table.

Method 1:

Dim WSheet as WorkSheet, Pivot as PivotTable
For Each WSheet in ThisWorkbook.WorkSheets
For Each Pivot in WSheet.PivotTables
Pivot.RefreshTable
Next
Next


Method 2:

ThisWorkbook.RefreshAll


Method 3:

Dim ws as WorkSheet
Dim pt as PivotTable
For Each ws In Activeworkbook.Worksheets
For Each pt In ws.PivotTables
pt.RefreshTable
Next pt
Next ws

Method 4:

Activeworkbook.RefreshAll
To refresh single pivot table follow the below method to execute in excel.

Method 5:

Sub Pivot_Table_Macro()
Dim pt As PivotTable
Set pt = ActiveSheet.PivotTables("My_Pivot")
pt.RefreshTable
End Sub
The methods which is shown above all to refresh the pivot tables in excel using macro(VBA). Thanks for visiting the website ScoreInExcel.

No comments:

Post a Comment

Post Top Ad

Your Ad Spot