Hi Mynda,
Please assist me to refresh the pivot which is updated based on the source data which appends data in 15 minute intervals.
I have tried a few VB codes from the internet, but did not help.
Warm Regards
GK
Use this code in a standard module:
Option Explicit
Public TimeInterval As Double
Sub RefreshQuery()
ThisWorkbook.Worksheets("SheetName").ListObjects("TableName").QueryTable.Refresh BackgroundQuery:=False
Debug.Print Now()
TimeInterval = Now() + TimeSerial(0, 15, 0)
Application.OnTime TimeInterval, "RefreshQuery"
End Sub
Sub StopTimer()
Application.OnTime earliesttime:=TimeInterval, procedure:="RefreshQuery", schedule:=False
End Sub
The following code should be placed in ThisWorkbook module:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopTimer
End Sub
Private Sub Workbook_Open()
RefreshQuery
End Sub
Thank you Catalin Bombea, will try that today and revert to you.
Regards
~GK
Bad luck mate, getting Run Time Error '9'. Subscript out of range.
Let me know if this information is enough. I had put your first code by create a module under Pivot and the second piece of code in the Pivot worksheet itself.
Regards
~GK
The code provided will refresh a power query.
(ThisWorkbook.Worksheets("SheetName").ListObjects("TableName").QueryTable.Refresh )
To refresh a pivot table:
I assume that you will change the generic names used for sheet and pivot name, right?
[...] and the second piece of code in the Pivot worksheet itself.
Please read more carefully the instructions, the second code must be placed into ThisWorkbook module, NOT a sheet module.
The following code should be placed in ThisWorkbook module:
Thanks mate, appreciate your help.
~GK