excel odbc ms query using cell as criteria value

  • Thread starter Thread starter mgunther
  • Start date Start date
M

mgunther

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?

Thanks
 
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)
 
Back
Top