Use cell in query

  • Does anybody know how you can use a cell from your excel worksheet in a sql query for data?

  • Where are you wanting to perform the query from? Query Anaylzer (ex) the only way is copy and paste if the server is remote to your machine and the file is local.

  • In Microsoft Query, don't hard-code a criteria value but rather define the value as a "hint" surrounded with brackets - [age], for example, can be to get data back for a certain age. 

    Let me know if this gets you on the right track...

    ~Steve

     

  • Yes that is what I want to have happen. Could you give me an example?

  • Hi

    If you search for parameter query in the Microsoft Excel Help you should be able to find the information you need. Here is the information I found in Excel 2003 help...

    "In your worksheet, type the values you want to use as criteria in the query 

    1. Click a cell anywhere in the external data range created with a parameter query
    2. On the External Data toolbar, click Query Parameters (right-clicking a cell in the data range also seems to work).
    3. In the list on the left side of the Parameters dialog box, click the parameter you want to change.
    4. Click Get the value from the following cell.
    5. On the worksheet, click the cell that contains the value you want to use.
    6. Click OK.
    7. To refresh the data, click Refresh Data on the External Data toolbar. "

    Hope this helps

    David

     

    If it ain't broke, don't fix it...

  • Donavon,

    Your first step should be to get familiar with Microsoft Query.  In Excel, go to data, get external data, and then new database query.  Microsoft Query will start to open.  You have to pick an existing data source or create a new one first.  Then Microsoft Query opens, usually in Wizard mode.  Pick tables and fields and criteria and get this to return to Excel.

    From there you should start to learn Microsoft Query without the wizard interface. 

    ~Steve

  • Thanks for all your help directing me to the right places. And I thought there was a trick to acomplish this.

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply