Parameter.RefreshOnChange Property (Excel)

True if the specified query table is refreshed whenever you change the parameter value of a parameter query. Read/write Boolean .

Syntax

expression. RefreshOnChange

expression A variable that represents a Parameter object.

Remarks

You can set this property to True only if you use parameters of type xlRange and if the referenced parameter value is in a single cell. The refresh occurs when you change the value of the cell.

Example

This example changes the SQL statement for the first query table on Sheet1. The clause "(ContactTitle=?)" indicates that the query is a parameter query, and the value of the title is set to the value of cell D4. The query table will be automatically refreshed whenever the value of this cell changes.

Set objQT = Worksheets("Sheet1").QueryTables(1) 
objQT.CommandText = "Select * From Customers Where (ContactTitle=?)" 
Set objParam1 = objQT.Parameters _ 
 .Add("Contact Title", xlParamTypeVarChar) 
objParam1.RefreshOnChange = True 
objParam1.SetParam xlRange, Range("D4")

See also

Parameter Object