ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell value to replace hard code in Query (https://www.excelbanter.com/excel-programming/421437-cell-value-replace-hard-code-query.html)

CLR

Cell value to replace hard code in Query
 
Hi All........
I have a macro that includes a Query that I have recorded and works fine.
It has hardcoded values in place for this section...... WHERE
(Q509M.Planner='LQ'....
I would like to be able to have a cell value replace the 'LQ' part. I have
tried numerous combinations and no joy.

I sucessfully use DBQ=" & NewFile & ";" in another part of the same Query
and it works fine to insert a Range().value assigned to NewFile, but just
can't seem to get this WHERE thing to cooperate.

Any help would be much appreciated.

Vaya con Dios,
Chuck, CABGx3



Mike

Cell value to replace hard code in Query
 
strWhere = Range("a1").value
WHERE (((Q509M.Planner='" & strWhere & "'))

"CLR" wrote:

Hi All........
I have a macro that includes a Query that I have recorded and works fine.
It has hardcoded values in place for this section...... WHERE
(Q509M.Planner='LQ'....
I would like to be able to have a cell value replace the 'LQ' part. I have
tried numerous combinations and no joy.

I sucessfully use DBQ=" & NewFile & ";" in another part of the same Query
and it works fine to insert a Range().value assigned to NewFile, but just
can't seem to get this WHERE thing to cooperate.

Any help would be much appreciated.

Vaya con Dios,
Chuck, CABGx3



CLR

Cell value to replace hard code in Query
 
OUTSTANDING!!!....Your suggestion solved my problem perfectly. Thank you
very very much.

Vaya con Dios,
Chuck, CABGx3



"Mike" wrote:

strWhere = Range("a1").value
WHERE (((Q509M.Planner='" & strWhere & "'))

"CLR" wrote:

Hi All........
I have a macro that includes a Query that I have recorded and works fine.
It has hardcoded values in place for this section...... WHERE
(Q509M.Planner='LQ'....
I would like to be able to have a cell value replace the 'LQ' part. I have
tried numerous combinations and no joy.

I sucessfully use DBQ=" & NewFile & ";" in another part of the same Query
and it works fine to insert a Range().value assigned to NewFile, but just
can't seem to get this WHERE thing to cooperate.

Any help would be much appreciated.

Vaya con Dios,
Chuck, CABGx3




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

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