![]() |
query criteria based on a changing list of values
I am trying to create a query that I can update that will return values based
on criteria from a list of values. Right now I have a range defined as =OFFSET(RangeValues!$B$2,0,0,COUNT(RangeValues!$B: $B),1) that holds the criteria I want to query by. I would like for the query to alter its selection criteria based on what is keyed into column B of the €śRangeValues€ť worksheet. Hopefully the finished product would be for me to add/delete/update values in column B, then run a macro (or refresh a query) that will return data based on what is currently in column B. I am connecting through an ODBC and can get the results I want if I copy and paste the criteria values into the SQL each time they change, but I cant get it to work based on a dynamic range of values. I am open to try solutions in VBA or the Excel Query Builder, I'm desperate. Any help would be greatly appreciated. |
query criteria based on a changing list of values
Check out "SQL Question" on 3/1/2006. It may help. I am after the extact
same thing but haven't had time to try cmd recommended in here. "bwilk77" wrote: I am trying to create a query that I can update that will return values based on criteria from a list of values. Right now I have a range defined as =OFFSET(RangeValues!$B$2,0,0,COUNT(RangeValues!$B: $B),1) that holds the criteria I want to query by. I would like for the query to alter its selection criteria based on what is keyed into column B of the €śRangeValues€ť worksheet. Hopefully the finished product would be for me to add/delete/update values in column B, then run a macro (or refresh a query) that will return data based on what is currently in column B. I am connecting through an ODBC and can get the results I want if I copy and paste the criteria values into the SQL each time they change, but I cant get it to work based on a dynamic range of values. I am open to try solutions in VBA or the Excel Query Builder, I'm desperate. Any help would be greatly appreciated. |
query criteria based on a changing list of values
something like this to get you started maybe:
function GetSQL() as String dim text as string dim cell as range for each cell in range("????").Cells text = text & " , " & cell.value next text = "SELECT " & MID(text,2) & "FROM WHATTABLE_ETC_ETC" GetSQL = text End Function "bwilk77" wrote in message ... I am trying to create a query that I can update that will return values based on criteria from a list of values. Right now I have a range defined as =OFFSET(RangeValues!$B$2,0,0,COUNT(RangeValues!$B: $B),1) that holds the criteria I want to query by. I would like for the query to alter its selection criteria based on what is keyed into column B of the €śRangeValues€ť worksheet. Hopefully the finished product would be for me to add/delete/update values in column B, then run a macro (or refresh a query) that will return data based on what is currently in column B. I am connecting through an ODBC and can get the results I want if I copy and paste the criteria values into the SQL each time they change, but I cant get it to work based on a dynamic range of values. I am open to try solutions in VBA or the Excel Query Builder, I'm desperate. Any help would be greatly appreciated. |
All times are GMT +1. The time now is 12:20 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com