Microsoft Office Online
Sign in to My Office Online (What's this?) | Sign in

Warning: You are viewing this page with an unsupported Web browser. This Web site works best with Microsoft Internet Explorer 6.0 or later, Firefox 1.5, or Netscape Navigator 8.0 or later. Learn more about supported browsers.

Email this linkEmail this link Printer-Friendly VersionPrinter-Friendly Version Bookmark and ShareShare
Entering Parameters in a Web Query
 
Applies to
Microsoft Excel 2002

When you use Web queries in Microsoft Excel, you can import refreshable data into your worksheets. You can also edit a Web query to prompt for variable parameters; for example, a Web query that gets stock quotes from a Web page can prompt for a parameter like a stock symbol each time you refresh the data.

Starting with a new Web query

  1. Use the New Web Query command (Data menu, Import External Data) to start a new Web query.
  2. In the New Web Query dialog box, enter the address of the Web page that contains the data you want to import into your worksheet. The Web page will appear in the dialog box similar to the example below:

    Using the New Web Query dialog box to select a table on a Web page

  3. Click on the arrow icon next to the tables that contain the data you want to import. If there are no icons next to tables on the page, click Show Icons at the top of the dialog box to display them. If you want to import the whole page, click the arrow icon in the upper left corner of the page.
  4. Save the query so you can edit it to add parameters. Click Save Query to save the query as a text file with an .iqy extension.
  5. If you want to query for the data now, click Import and follow the prompts to put the selected data into your worksheet.

Editing a Web query

  1. To edit a saved Web query, navigate to the query file on your computer and right-click on the file. The query file will have the name you gave it, and will end with an .iqy extension.

    Note  If you cannot find a file that you have just saved, it may be in a hidden folder. See Microsoft® Windows® Help to get help on viewing hidden folders.

  2. On the shortcut menu, click Edit with Notepad. The query opens in Microsoft Notepad so you can make changes to the file.
  3. In Notepad, you will see the contents of the query file. In the text, find the Web address where the imported data originated. For example:

    http://moneycentral.msn.com/investor/external/excel/quotes.asp

    At the end of the Web address, type the following:

    ?SYMBOL=["parameter", "Text that will prompt user to enter parameter"]

    So that the whole line looks like:

    http://moneycentral.msn.com/investor/external/excel/quotes.asp?SYMBOL=["QUOTE", "Enter stock, fund or other MSN MoneyCentral Investor symbols separated by commas."]

  4. After adding this text, click Save on the File menu and close Notepad.

Running a Web query that contains parameters

  1. After you have edited your Web query, go into Excel and open the query with the Import Data command (Data menu, Import External Data).
  2. Select the Web query and click Open.
  3. If you want to edit the settings for the parameters, click Parameters in the Import Data dialog box. In the Parameters dialog box, you can change the text the user will see when opening the query (under Prompt for value using the following string). You can also change what value the query should return (under Use the following value) or have the query get data from another cell (under Get the value from the following cell). If you choose this last option, you can also refresh the query when the referenced cell value changes by selecting Refresh automatically when cell value changes.
  4. Select the location in the worksheet where you want to import the data from the Web query and click OK.
  5. The Enter Parameter Value dialog box prompts you to enter parameters, unless you have set the query to return a specific value.
© 2009 Microsoft Corporation. All rights reserved.