Refreshing all the pivot tables in my excel workbook with a macro

前端 未结 10 1346
长发绾君心
长发绾君心 2020-11-29 20:32

I have a workbook with 20 different pivot tables. Is there any easy way to find all the pivot tables and refresh them in VBA?

10条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 20:57

    Yes.

    ThisWorkbook.RefreshAll
    

    Or, if your Excel version is old enough,

    Dim Sheet as WorkSheet, Pivot as PivotTable
    For Each Sheet in ThisWorkbook.WorkSheets
        For Each Pivot in Sheet.PivotTables
            Pivot.RefreshTable
            Pivot.Update
        Next
    Next
    

提交回复
热议问题