vba to refresh pivot table not working

vbanovice123

Board Regular
Joined
Apr 15, 2011
Messages
91
Sub RefreshPivotTables()
'
' Macro1 Macro
'
'
Sheets("Agency_Data").Select
Range("B25").Select
ActiveSheet.PivotTables("PivotTable_Agency_Data").PivotCache.Refresh
ActiveWorkbook.Close SaveChanges:=True

End Sub
 
I believe you'll have to run this whenever you've refreshed the SQL tables and want to update the new data to your pivot tables as well. You might want to add that line to one of the events in your workbook (workbook open should work) and your pivottables should be up to date whenever you open the workbook & need the data.

Thanks a lot, I'll try that.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,225,156
Messages
6,183,246
Members
453,152
Latest member
ChrisMd

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
Back
Top