sadavies2906
New Member
- Joined
- Feb 5, 2011
- Messages
- 45
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
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