• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Refresh all Pivot Tables

Dokat

Member
I have below code where i need it to update all the pivot tables if the values between A:C changes. However it is not working. Can anyone help? Thanks


Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("A:C")) Is Nothing Then

Call Module6.InnovationTrackerRemoveDuplicates
Call Module7.RightFunction
Call Module8.UpdateTime2
Call Module9.UpdateGeo2
Call Module16.ACVANIInno

Dim ws As Worksheet
Dim pt As PivotTable

For Each ws In ActiveWorkbook.Worksheets

For Each pt In ws.PivotTables

pt.PivotCache.Refresh

Next
Next

End If


End Sub
 
Hi Dokat,

Please try the below code:

Sub RefreshAllPivotTables()

Dim PT As PivotTable
Dim WS As Worksheet

For Each WS In ThisWorkbook.Worksheets

For Each PT In WS.PivotTables
PT.RefreshTable
Next PT

Next WS

End Sub

Note: It will refresh all the pivots present in your workbook.
 
Doesn't Workbook.RefreshAll do it? eg:
Thisworkbook.refreshall

If not then refresh the pivotcaches with the likes of:
Code:
Sub blah()
Dim pc As PivotCache
For Each pc In ThisWorkbook.PivotCaches
  pc.Refresh
Next pc
End Sub
 
Back
Top