BeforeRefresh Event [Excel 2003 VBA Language Reference]

Occurs before any refreshes of the query table. This includes refreshes resulting from calling the Refresh method, from the user's actions in the product, and from opening the workbook containing the query table.

Private Sub QueryTable_BeforeRefresh(CancelAs Boolean)

CancelFalse when the event occurs. If the event procedure sets this argument to True, the refresh doesn't occur when the procedure is finished.

Example

This example runs before the query table is refreshed.

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

Applies to | QueryTable Object

See Also | AfterRefresh Event | QueryTable Object Events | Using Events with the QueryTable Object