VBA: Refresh all pivot tables when I delete lines in my dataset

DECOVIOTI

New Member
Joined
Dec 11, 2020
Messages
12
Office Version
  1. 2019
Platform
  1. Windows
Hello Guys
I have in my excel spreadsheet a high number of pivot tables and a worksheet called "Data". I would like to know if is possible after delete some lines in this Data tab, if the all pivot tables can be refreshed automatically.
Can you pls help me?
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

ExcelGzh

Board Regular
Joined
Mar 29, 2020
Messages
130
Office Version
  1. 365
Platform
  1. Windows
This is the code I have for the Worksheet_Activate event for any sheet that has a pivot table. Unless you have some cells somewhere else that use the data in the pivot tables, there is no need to update them until you go to a sheet that has pivot tables. If you do have dependent cells then you will have to attach the RefreshAll command to some other event such as Worksheet_Change.

VBA Code:
Private Sub Worksheet_Activate()
  'Pivot tables don't update automatically.  This forces an update when the user goes to this sheet.
  ThisWorkbook.RefreshAll
End Sub
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,123,517
Messages
5,602,120
Members
414,505
Latest member
quoctrungvu99

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top