QueryTable BeforeRefresh Event



Syntax
Private Sub QueryTable_BeforeRefresh(Cancel As Boolean)
Enter Code
End Sub

This event occurs before the query tables refreshes. This event can occur by calling the refresh method of the query table or when the workbook that contains the query table is opened.

Required Parameters
Cancel
The cancel parameter will determine if the query table is refreshed or not. If the parameter remains set to true then the query table will be refreshed. If the parameter is set to false then the query table will not refresh.

Example
Private Sub QueryTable_BeforeRefresh(Cancel As Boolean)
 a = MsgBox("Refresh Now?", vbYesNoCancel)
 If a = vbNo Then Cancel = True
 MsgBox Cancel
End Sub

Result
This example runs before the query table is refreshed.