ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   excel odbc ms query using cell as criteria value (https://www.excelbanter.com/excel-programming/426858-excel-odbc-ms-query-using-cell-criteria-value.html)

mgunther

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?

Thanks

Patrick Molloy[_2_]

excel odbc ms query using cell as criteria value
 
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)







"mgunther" wrote:

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



All times are GMT +1. The time now is 04:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com