RefreshOnChange Property 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")