Power query refresh

sadavies2906

New Member
Joined
Feb 5, 2011
Messages
44
Refreshing pivot query
I have the following macro that refreshes a power query and then refreshes the pivot table linked to the results


Sub REFRESH()
'
' REFRESH Macro
'

Application.ScreenUpdating = False
Sheets("RAW DATA").Select
Selection.ListObject.QueryTable.REFRESH BackgroundQuery:=False
Sheets("Work to List EP").Select
ActiveSheet.PivotTables("Work to List EP").PivotCache.REFRESH
Sheets("Overview").Select
Range("A1").Select
Application.ScreenUpdating = True
End Sub
I am trying to get a message box to appear while the query is running but am unable to get this to work.
I have seen the following code on Microsoft website and would like to include it in my refresh macro if that is possible and ideas what the code should look like?

With Worksheets(1).QueryTables(1)
If .Refreshing Then MsgBox "Query is currently refreshing: please wait"
Else
.Refresh BackgroundQuery := False
.ResultRange.Select
End If
End With

Any help appreciated

Stephen
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Watch MrExcel Video

Forum statistics

Threads
1,118,970
Messages
5,575,287
Members
412,653
Latest member
JyothiGrace
Top