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

前端 未结 10 1333
长发绾君心
长发绾君心 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:48

    In certain circumstances you might want to differentiate between a PivotTable and its PivotCache. The Cache has it's own refresh method and its own collections. So we could have refreshed all the PivotCaches instead of the PivotTables.

    The difference? When you create a new Pivot Table you are asked if you want it based on a previous table. If you say no, this Pivot Table gets its own cache and doubles the size of the source data. If you say yes, you keep your WorkBook small, but you add to a collection of Pivot Tables that share a single cache. The entire collection gets refreshed when you refresh any single Pivot Table in that collection. You can imagine therefore what the difference might be between refreshing every cache in the WorkBook, compared to refreshing every Pivot Table in the WorkBook.

提交回复
热议问题