Excel: passing a cell value to a SQL query

I’ve just begun working with SQL, and have been thinking that it would very much simplify my life when I’m working with Excel.

So I was very happy to discover that, when editing a OLE DB query of another Excel spreadsheet, you can use an SQL query.

So far, so good.

However, to really be useful, I need to be able to dynamically generate the query from cell values, not hard code it every time.

For example,
SELECT * FROM Sheet1$ WHERE Cell Value = “Fred”;

But instead of using Fred, I’d want to pass the value of a cell.

Doesn’t seem to be working no matter what syntax I use to indicate the cell. Google showed one other guy who had exactly the same question I have… but you gotta pay for the answer.

C’mon, there’s gotta be a way to do this, right?

Extra points if the solution doesn’t involve any VBA.

I don’t know how to do this without VBA but it might be possible. Where is it that this query appears?

Here is the best place to ask. Requires free registration.