Chris has attended:
Excel VBA Introduction course
Excel VBA Intermediate course
Pivot Tables
What's the simplest code available to refresh pivot tables and update the data source?
RE: Pivot Tables
Hi Chris,
Thank you for your question. Below is some code which you can build into an existing macro, which will refresh all pivot tables in your workbook:
Dim Pt As PivotTable
For Each Pt In ActiveSheet.PivotTables
Pt.RefreshTable
Next pt
To update the source data, you could either write or record some code and paste it into the beginning of your Pivot Table macro which copies and pastes the new data into the location of the old data, or you could tell the Pivot Table macro to find the new data in a different sheet by using code similar to the code below:
ActiveWorkbook.Sheets("Sheet_Name").Select
I hope this helps
Kind regards
Marius Barnard
Excel Trainer