Auto refresh of Pivot Table

  • Thread starter Thread starter K. Georgiadis
  • Start date Start date
K

K. Georgiadis

I found the following code on C. Pearson's website:

Sub Auto_Open()
Application.OnSheetActivate = "UpdateIt"
End Sub

Sub UpdateIt()
Dim iP As Integer
Application.DisplayAlerts = False
For iP = 1 To ActiveSheet.PivotTables.Count
ActiveSheet.PivotTables(iP).RefreshTable
Next
Application.DisplayAlerts = True
End Sub

However, I cannot make it to work either within a
separate module or within "This workbook." Does it
perhaps need to be specifically declared as a Public Sub?
 
Do you remember in which section of Debra's website you
found this? It seems that this code unprotects the
worksheet, refreshes it and then resets the protection.
Is that how it works?
 
Back
Top