VBA - On.refresh() function

296 views Asked by At

I want to execute a bunch of functions, every time a refresh happens on the web query i have on the same excel file. The web query is fetching data every 10 mins and a pivot sits on the data.

How can i write a code in order to refresh the pivot every time the refresh happen automatically? So what i really need is -

OnRefresh() {

update pivot table

}

Thanks!

1

There are 1 answers

0
hnk On

Use the following code PivotCache.Refresh For e.g.

Worksheets(1).PivotTables(1).PivotCache.Refresh

http://msdn.microsoft.com/en-us/library/office/ff195521%28v=office.15%29.aspx

You can substitute 1 with PivotTableName if you like. Invoke this line in the event triggered by the web-page getting fetched or as the last line of the code doing the refresh.