Hi
You need a code invoked after the cell entry is changed. You can use the
worksheet's Change event (the active cell address must be checked at start,
otherwise the query is refreshed whenever you change anything on worksheet),
or the user starts the procedure manually (shortcut, command button, or from
menu).
The code changes the CommandText property of query object, and then
refreshes the query. But first you have to create the query with any fixed
values as parameters.
Below is a segment of code from one of my workbooks as example:
.....
kuu = ActiveSheet.Range("D1").Value
aasta = ActiveSheet.Range("D2").Value
'
Set qtQtrResults = Worksheets("Tasud").QueryTables(1)
Sheets("Tasud").Activate
ActiveSheet.Range("C2").Select
With qtQtrResults
.CommandType = xlCmdSql
.CommandText = _
"SELECT a.tabn, a.sisestus As 'arvestus', b.tyyp, b.kuupaev,
a.tl, a.summa FROM tasud a, lahendus b WHERE b.lahendus=a.sisestus AND
a.tabn<>'' AND a.tl<'060' AND Year(b.kuupaev)=" & aasta & " AND
Month(b.kuupaev)=" & kuu & " ORDER BY a.tabn, a.sisestus"
.Refresh
End With
.....
Arvi Laanemets