passing criteria via Get External Data from a macro
Thanks for the help - it's given me something to work with. I'm still
having trouble understanding the use of setting the variables in your
example (vVar and sSql) to using them in the macro to refresh the
data. I've tried some variations but without success.
thanks for any additional help.
Matthew
"Tom Ogilvy" wrote in message ...
Look at the SQL portion of the query
Select * from Table where State = 'WT'
in you code change this to
vVar = "WT"
sSql = "Select * from Table where State ='" & vVar & "'"
You can also add a criteria in msquery and rather than put in a value in the
criteria put in square backets and you will bet a prompt to enter the value
when you refresh. If you view the SQL in msquery, it will look like
where State = ?
Also, back in Excel you can right click on the query (once it is a parameter
query) and select parameter from the pop up and in that, designate a cell to
retrieve the value from.
--
Regards,
Tom Ogilvy
|