

April 2, 2021

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


November 8, 2013

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


November 8, 2013

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:

Answers Post
1 Guest(s)
