Refresh external data in Excel 2010 while the file is open in the background but not in use

hoz picture hoz · Nov 12, 2012 · Viewed 11.9k times · Source

I am using Excel 2010 to query MS SQL databases and other Excel files to import data. I have set different intervals for each data connection (10 connections). In excel this data is sliced and diced to create meaningful charts which are presented in PowerPoint.

I was able to find a VB ad-in for PowerPoint to update data from excel automatically while the presentation is being looped.

I keep the excel file open in the background (Behind PowerPoint) since PowerPoint tries to open the excel sheet every time a chart is being refreshed. My issue is in Excel, since it is not actively used the data connections do not refresh automatically.

I have tried various solutions, but they require the vb / macro to be initiated manually, however I need this to refresh data automatically based on the timings provided for the data connections.

Is there a VB code I can use in Excel to refresh the data connections while the excel workbook is opened but not actively used?

Appreciate if you could point me to a relevant post, or guide me.

Thank you in advance.

Answer

hoz picture hoz · May 19, 2015

I found the solution to refresh the Pivot cache if the data in a sheet changes. I'm updating this post in case anyone else needs the solution. Thank you very much for your help.

Private Sub Worksheet_Change(ByVal Target As Range) 

Worksheets("Pivot table").PivotTables("PivotTable1").PivotCache.Refresh

End Sub

Follow this link for further information on this issue - http://www.get-digital-help.com/2011/06/13/auto-refresh-a-pivot-table-in-excel/#comment-52745