vba program to actualice pivotTable

AndreasL

New member
Joined
Oct 12, 2011
Messages
4
Reaction score
0
Points
0
Hi,

I want to actualice all PT with an Makro. All PT are indipendent from each other and is also on different worksheets. Following programm do I have but it isn't working and I don't know why:

Code:
Dim pvt As PivotTable, j As Integer
For j = 1 To ActiveSheet.PivotTables.Count
Set pvt = ActiveSheet.PivotTables(j)
ActiveSheet.PivotTables(j).PivotCache.Refresh
Next

Another sugestion was to activate the different worksheets but it is also not working:

Code:
Dim wks As Worksheet, pvt As PivotTable, i As Integer, j As Integer
For i = 1 To ActiveWorkbook.Worksheets.Count
Set wks = ActiveWorkbook.Worksheets(i)
For j = 1 To ActiveSheet.PivotTables.Count
'Set pvt = ActiveSheet.PivotTables(j)
ActiveSheet.PivotTables(j).PivotCache.Refresh
Next
Next


Thank you for your help.
 
Last edited by a moderator:
Why not just try

ActiveWorkbook.RefreshAll
 
Thank you very much. This was a really easy solution. Thank you.
 
Back
Top