Luis Diaz
asked on
VBA Excel: Refresh pivot tables & tables automatically
Hello experts, I have the following procedure which allows me to refresh the various pivot tables I would like to add some enhancements:
1. Run the procedure after I change a data or after a save
2. Include in the procedure the refresh of the various tables in the workbook
Thank you very much for your help.
Sub Refresh_Pivot()
Dim PT As pivotTable
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
For Each PT In WS.PivotTables
PT.PivotCache.Refresh
Next PT
Next WS
End Sub
1. Run the procedure after I change a data or after a save
2. Include in the procedure the refresh of the various tables in the workbook
Thank you very much for your help.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Ok, I added in ThisWorkbook and it works perfectly. Thank you again for your help!
You're welcome! Glad it worked as desired.
Thanks for the feedback.
Thanks for the feedback.
ASKER
Should I add those procedures inside modules, Sheets or ThisModules?