0

I have a query in a workbook which SQL statement is:

SELECT field1, field2, field3 FROM table

Now, I would like to update query to filter data using criteria from my workbook as so:

SELECT field1, field2 FROM table WHERE field3 = Sheet1!A1 -- Invalid statement!

How can I achieve this within MS Query (without VBA)?

LS_ᴅᴇᴠ
  • 10,823
  • 1
  • 23
  • 46
  • I didn't find *official* answers but I guess it's impossible (in the same query). My guess is that you need to have two queries (one to obtain the value from Sheet1!A1) and then a second which will contain the value that you obtain in the first query (instead of a reference to Sheet1!A1) – Chris Oct 03 '13 at 15:51
  • How about this [method?](http://stackoverflow.com/questions/1285686/excel-use-a-cell-value-as-a-parameter-for-a-sql-query) – Automate This Oct 03 '13 at 15:52
  • @PortlandRunner Good catch. It seems that I said something wrong. I didn't know that batch queries were supported in this case. I will remove my comment if LS_dev confirms that it works. – Chris Oct 03 '13 at 15:55
  • @PortlandRunner I can't make it work. I'm using Excel files as data source, and I think this driver doesn't support parameters. – LS_ᴅᴇᴠ Oct 04 '13 at 08:36

0 Answers0