gogo wrote:
I'm trying to add to my Excel spreadsheet a query that goes to the
external database (also an Excel file) and of course pulls out
certain data. The problem is that the typical query wizzard enables
entering as a parameter only fixed value. My question is if it's
possible to add as a criteria valule reference link to selected cell
in the spreadsheet. In other word to make the query take the
parameter form the certain cell in the spreadsheet. Here is an
example of condition: .......WHERE (`Sheet1$`.Year=2005) AND
(`Sheet1$`.Month=6).......I'd like the 'month' parameter to be taken
from the specified cell ....how to do it ? Is it possible in Excel
SQL ?
You need to set up the condition as a prompt parameter, then change it to a
range parameter. If you're using MSQuery, you would use brackets
..Month = [Enter Month]
to create a prompt parameter. Then, back in Excel, you click on the
Parameters button of the External Data Toolbar and change the parameter type
to Range.
If you're doing this in SQL or VBA (by building a SQL string), it's the
question mark (?) that holds the place of the parameter
..Month=?
Again, you click the Parameters button to change the type.
See
http://www.dicks-clicks.com/excel/Ex...htm#Parameters for more
information and examples.
--
Dick Kusleika
MVP - Excel
Daily Dose of Excel
http://www.dicks-blog.com