Refresh pivots apparaissent apparemment erreur

Voici mon code:

Sub Atualiza_pivots() ActiveWorkbook.RefreshAll End Sub 

Je fais un code simple qui rafraîchit tous les pivots dans le classur, mais si certains pivots se rafraîchissent, il ne me paraît pas, alors je ne sais pas quand il y a une erreur. J'essaie de créer un autre code, mais il ne semble pas apparaître.

 Sub Atualiza_pivots() On Error GoTo Err ActiveWorkbook.RefreshAll Exit Sub Err: MsgBox "Há pivots com erro, verifique." End Sub 

Je vous remercie.

La méthode RefreshAll ne fonctionne que si BackgroundQuery est défini sur True, essayez de faire une boucle dans chaque table et l'actualiser manuellement:

 Sub Refresher() Dim wks As Worksheet Dim pvt As PivotTable For Each wks In Worksheets For Each pvt In wks.PivotTables If pvt.PivotCache.BackgroundQuery = False Then pvt.PivotCache.BackgroundQuery = True pvt.RefreshTable pvt.PivotCache.BackgroundQuery = False Else pvt.RefreshTable End If Next pvt Next wks End Sub 

Thx pour l'aide D_Zab

 Sub Atualiza_pivots() Dim wks As Worksheet Dim pvt As PivotTable For Each wks In Worksheets For Each pvt In wks.PivotTables On Error GoTo Err pvt.PivotCache.Refresh Next pvt Next wks Exit Sub Err: MsgBox pvt & " com erro." End Sub