Use the Lookup Wizard

Một phần của tài liệu Sử dụng Excel thiết lập cơ sở dữ liệu (Trang 132 - 136)

Chapter 7: Automate Repetitive Database Tasks

4.5 Use the Lookup Wizard

You can use Excel’s Lookup Wizard to create a lookup formula that returns the value at the intersection of a given row and column, provided there is a group of worksheet cells that have both row and column labels. The Lookup Wizard uses a combination of the INDEX and MATCH worksheet functions to create the formula.

C H A P T E R 4 ■ F I N D D ATA 113

Quick Start

To use the Lookup Wizard, in Excel 2007, click Formulas ➤(Solutions) Lookup. In Excel 2003, click Tools ➤Lookup. Follow the instructions in the wizard.

Note If the Lookup command is not available, see the sidebar in the “How To” section for how to make the command visi ble.

How To

To use the Lookup Wizard, in Excel 2007, click Formulas ➤(Solutions) Lookup. In Excel 2003, click Tools ➤Lookup.

1. In the wizard’s Step 1 of 4 page, in the Where Is the Range to Search, Including Row and Column Labels box, type the cell reference or select the cells to search. Then click Next.

2. In the wizard’s Step 2 of 4 page, in the Select the Column Label list, select the column label reference.

3. In the Select the Row Label list, select the row label reference. Then click Next.

4. In the wizard’s Step 3 of 4 page, click the Copy Just the Formula to a Single Cell option to return the formula into a specific cell, or click the Copy the Formula and Lookup Parameters option to return the result and the lookup parameters into specific cells.

Then click Next.

MAKE THE LOOKUP COMMAND VISIBLE

If the Lookup command is not visible in the Formulas ➤(Solutions) group (in Excel 2007) or on the Tools menu (in Excel 2003), you can add it by doing the following in Excel 2007:

1. Click Office Button ➤Excel Options.

2. In the left pane, click Add-Ins.

3. In the Manage list toward the bottom of the screen, with the Excel Add-Ins selection visible, click the Go button.

4. In the Add-Ins Available list, select the Lookup Wizard check box, and click OK.

In Excel 2003, do the following:

1. Click Tools ➤Add-Ins.

2. Select the Lookup Wizard check box, and click OK.

5. If you clicked the Copy Just the Formula to a Single Cell option in the previous step 4 of this list, in the wizard’s Step 4 of 4 page, type the cell reference or select the cell to return the formula. Then click Finish.

If you clicked the Copy the Formula and Lookup Parameters option in step 4 of this list, do the following:

a. In the wizard’s Step 4 of 6 page, in the Type or Select a Cell and Then Click Next box, type the cell reference or click the cell into which you want to return the first parameter. Then click Next.

b. In the wizard’s Step 5 of 6 page, in the Type or Select a Cell and Then Click Next box, type the cell reference or click the cell into which you want to return the second parameter. Then click Next.

c. In the wizard’s Step 6 of 6 page, in the Type or Select a Cell and Then Click Finish box, type the cell reference or click the cell into which you want to return the for- mula. Then click Finish. The formula—and parameters, if you selected that option earlier—are returned into the specified cells.

Try It

In this exercise, you will use the Lookup Wizard to locate specific data values and use them in sales inventory calculations.

Open the ExcelDB_Ch04_01-05.xls file, and click the Lookups worksheet tab.

In cells H10 through J13, use the Lookup Wizard to calculate the sales inventory for the number of vehicles in cells B2 through B5 multiplied by the vehicles’ sales prices in cells E2 through E5, as follows:

1. In Excel 2007, click Formulas ➤(Solutions) Lookup. In Excel 2003, click Tools ➤Lookup.

2. Click the Where Is the Range to Search, Including the Row and Column Labels box, select cells A1 through B5, and click Next.

3. In the Select the Column Label list, select Price Each.

4. In the Select the Row Label list, select Cars, and click Next.

5. Click Next again.

6. Click the Type or Select a Cell and Then Click Finish box, click cell H10, and click Finish.

7. Repeat steps 1 through 6 for cells H11 through H13, respectively, specifying the follow- ing values in the Lookup Wizard:

• For cell H11, search cells A1 through B5, and use the Price Each column and Trucks row labels.

• For cell H12, search cells A1 through B5, and use the Price Each column and Vans row labels.

• For cell H13, search cells A1 through B5, and use the Price Each column and Mini- vans row labels.

C H A P T E R 4 ■ F I N D D ATA 115

8. Repeat steps 1 through 6 for cells I10 through I13, respectively, specifying the following values in the Lookup Wizard:

• For cell I10, search cells D1 through E5, use the In Stock column and Cars row labels.

• For cell I11, search cells D1 through E5, use the In Stock column and Trucks row labels.

• For cell I12, search cells D1 through E5, use the In Stock column and Vans row labels.

• For cell I13, search cells D1 through E5, use the In Stock column and Minivans row labels.

Now, calculate the subtotals for cells H10 through I13:

1. Click cell J10, type =PRODUCT(H10:I10), and press Enter.

2. Drag the fill handle (the small black box in the lower right corner of cell J10) to cell J13.

Connect to Other Databases

You can use Excel to connect to any external database for which you have an accompanying ODBC driver or OLE DB provider (software translation programs that allow Excel to connect to external data). Once you have connected to an external database, you can use most if not all of Excel’s built-in features for viewing, finding, refreshing, and analyzing the data associated with that database.

Some of the ODBC drivers and OLE DB providers that ship with Excel include the following:

• Microsoft Office Excel

• Microsoft Office Access

• Microsoft SQL Server

• Microsoft Windows SharePoint lists and document libraries

• Microsoft Business Solutions

• Microsoft Visual FoxPro

• dBASE

• Oracle

• Paradox

• Text file databases

This chapter describes how to establish connections from Excel to other external Excel databases as well as Access databases, SQL Server databases, and OLAP databases hosted in SQL Server Analysis Services. For information on how to connect to other database types, contact the specific database’s manufacturer.

Một phần của tài liệu Sử dụng Excel thiết lập cơ sở dữ liệu (Trang 132 - 136)

Tải bản đầy đủ (PDF)

(245 trang)