0
I got this code in a question here, to update the dynamics of a spreadsheet, but when running the macro, it presents error - pt.RefreshTable.
Run-time error '1004': Reference isn’t Valid. (en.Refreshtable)
Private Sub Worksheet_Activate()
'Dimensionar variáveis
    Dim pt As PivotTable
    Dim ws As Worksheet
'Atualiza Pivot Tables uma a uma
    For Each ws In ActiveWorkbook.Worksheets
        For Each pt In ws.PivotTables
            pt.RefreshTable
            Next pt
        Next ws
Add to question which error appeared.
– Tony
@Tony Run-time error '1004': Reference isn’t Valid. (en.Refreshtable)
– Lucas Daros