excel odbc ms query using cell as criteria value



I have a excel odbc ms query of a sql db. I need to be able to pull one of
the criteria value from annother cell in excel that will change once a month.
Can anyone tell me how I would do this?




Patrick Molloy

your SQL would look like this:

SELECT [selection] FROM [source] WHERE [column] = '%token%'

in VBA, you could replace the token by the value in a cell...
lets say a string variable, sSQL contains the SQL text above, then

sSQL = REPLACE(sSQL,"%token%", sheet1.range("B1").Value)

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question