'Multiple PivotTables and Cache won't refresh

I have 2 sheets where I paste data into daily. I have premade PivotTables (source data is columns A:S).

After I paste my data, I run a macro but noticed the PivotTables don't refresh until I hit the 'Refresh All' button under the Data tab. Is my code missing something?

Application.ScreenUpdating = False

Dim pc As PivotCache
For Each pc In ThisWorkbook.PivotCaches
    pc.Refresh
Next pc

ThisWorkbook.RefreshAll

So I thought I need to refresh the PivotCache first of course, and it goes through all PivotCaches, and then RefreshAll to refresh the actual tables.

Not sure what I'm missing. Any help is appreciated, thanks!



Solution 1:[1]

I struggled with this same issue. Try adding a simple "Calculate" before the .RefreshAll. You also want to make sure to turn ScreenUpdating back on.

Application.ScreenUpdating = False

Dim pc As PivotCache
For Each pc In ThisWorkbook.PivotCaches
    pc.Refresh
Next pc

Calculate
ThisWorkbook.RefreshAll

Application.ScreenUpdating = True

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DKoontz