29.05.2016 Views

Excel 2010 Fomulas

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 8: Using Lookup Functions 227<br />

The following formula (in cell B4) uses the MATCH function to return the position of the Month<br />

within the MonthList range. For example, if the month is January, the formula returns 2 because<br />

January is the second item in the MonthList range. (The first item is a blank cell, D1.)<br />

=MATCH(Month,MonthList,0)<br />

The formula in cell B5 works similarly but uses the ProductList range:<br />

=MATCH(Product,ProductList,0)<br />

The final formula, in cell B6, returns the corresponding sales amount. It uses the INDEX function<br />

with the results from cells B4 and B5.<br />

=INDEX(Table,B4,B5)<br />

You can, of course, combine these formulas into a single formula, as shown here:<br />

=INDEX(Table,MATCH(Month,MonthList,0),MATCH(Product,ProductList,0))<br />

Another way to accomplish a two-way lookup is to provide a name for each row and<br />

column of the table. A quick way to do this is to select the table and use Formulas➜<br />

Defined Names➜Create from Selection. After creating the names, you can use a simple<br />

formula to perform the two-way lookup, such as<br />

=Sprockets July<br />

This formula, which uses the range intersection operator (a space), returns July sales<br />

for Sprockets. To refer to the cells where the month and product are entered, use<br />

=INDIRECT(Month) INDIRECT(Product)<br />

This formula converts the values in the cells Month and Product into range references and<br />

finds the intersection. See Chapter 3 for details about the range intersection operator.<br />

Performing a two-column lookup<br />

Some situations may require a lookup based on the values in two columns. Figure 8-13 shows an<br />

example.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!