Microsoft KB Archive/211926

= HOW TO: Specify Dynamic Web Query Parameters in Excel 2000 =

Article ID: 211926

Article Last Modified on 10/8/2003

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition

-



This article was previously published under Q211926



For a Microsoft Excel 97 version of this article, see 162051.

For a Microsoft Excel 98 version of this article, see 190803.

IN THIS TASK
SUMMARY Example 1: Use the Enter Parameter Value Dialog Box Example 2: Specify Cell Values Example 3: Set Parameter Value
 * How to Change the Parameter Value

REFERENCES



SUMMARY
This step-by-step article shows you how to specify dynamic Web query parameters in Excel 2000. A Web query allows you to retrieve data stored on your intranet, the Internet, or the World Wide Web. A Web query can use static parameters, dynamic parameters, or a combination of both. Queries with static parameters send a query without any input; queries with dynamic parameters prompt you for input. Regardless of the type of parameters in the query, the requested information is pulled from an Internet or an intranet site, and the results are placed in a worksheet.

When you use dynamic parameters, you can use the following three methods to obtain the parameter values:
 * Use a dialog box that prompts you to type the values.
 * Specify the values to use.
 * Get the values from a worksheet cell.

This article provides a sample dynamic Web query and the steps for setting the parameter values for the query, using each of the three methods. In each of the examples, the same Web query file is used to generate the initial results that are returned to a worksheet. After you perform a query to return data to a worksheet, the Web query file is no longer used to update the data in the worksheet; the query is stored in the worksheet.

In some of the examples below, you use the Parameters dialog box to make changes to the parameters in a query. Note that these changes do not affect the Web query file you initially use to run the query; any changes you make to the query parameters are stored in the worksheet.

NOTE: Microsoft does not guarantee the examples will work indefinitely.

back to the top

Example 1: Use the Enter Parameter Value Dialog Box

 * 1) Save and close any open workbooks, and then create a new workbook.
 * 2) On the Data menu, point to Get External Data, and then click Run Saved Query.
 * 3) Click Microsoft Investor Stock Quotes.iqy in the Run Query dialog box, and then click Get Data.

NOTE: The Microsoft Investor Stock Quotes.iqy file is in the Program Files\Microsoft Office\Queries folder.
 * 1) In the Returning External Data to Microsoft Excel dialog box, click OK.
 * 2) In the Enter Parameter Value dialog box, type msft in the box, and then click OK.

A detailed stock quote for Microsoft Corp. (MSFT) is returned to the worksheet.

back to the top

Example 2: Specify Cell Values

 * 1) Switch to Sheet2 in the workbook, and then type msft in cell A1.
 * 2) With A2 selected, point to Get External Data on the Data menu, and then click Run Saved Query.
 * 3) Click Microsoft Investor Stock Quotes.iqy in the Run Query dialog box, and then click Get Data.
 * 4) In the Returning External Data to Microsoft Excel dialog box, click Parameters.

The Parameters dialog box appears. Notice the option for this Web query uses a prompt for the parameter value.
 * 1) In the Parameters dialog box, click Get the value from the following cell, click cell A1 to insert the reference =Sheet2!$a$1 in the box, and then click OK.
 * 2) Click OK in the Returning External Data to Microsoft Excel dialog box.

A detailed stock quote for Microsoft Corp. (MSFT) is returned to the worksheet.
 * 1) Change the contents of cell A1 in Sheet2 to a different (valid) stock symbol.
 * 2) On the External Data toolbar, click the Refresh Data button.

Because the contents of cell A1 changed, a detailed stock quote for the new stock symbol is returned to the worksheet.

back to the top

Example 3: Set Parameter Value

 * 1) Switch to Sheet 3 in the workbook, and then type msft in cell A1.
 * 2) With A2 selected, point to Get External Data on the Data menu, and then click Run Saved Query.
 * 3) Click Microsoft Investor Stock Quotes.iqy in the Run Query dialog box, and then click Get Data.
 * 4) In the Returning External Data to Microsoft Excel dialog box, click Parameters.
 * 5) In the Parameters dialog box, click Use the following value, type msft in the box, and then click OK.
 * 6) In the Returning External Data to Microsoft Excel dialog box, click OK.

A detailed stock quote for Microsoft Corp. (MSFT) is returned to the worksheet.
 * 1) On the External Data toolbar, click the Refresh Data button.

You are not prompted for any value, and the same results are returned to your worksheet. However, if you click Refresh Data on another day, an updated stock quote for Microsoft Corp. is returned to the worksheet.

back to the top

How to Change the Parameter Value
If you use a specific value for a parameter, as in the previous example, you can change this value in the Parameters dialog box.
 * 1) Click any cell in the results that are returned to Sheet3.
 * 2) On the External Data toolbar, click the Query Parameters button.
 * 3) In the Parameters dialog box, change the contents of the Use the following value box to a different stock symbol, and then click OK.
 * 4) On the External Data toolbar, click the Refresh Data button.

The stock quote in Sheet3 is changed to reflect the new stock symbol that you typed in step 3.

back to the top

