18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

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

Part II<br />

Working with Formulas and Functions<br />

To simplify things, the worksheet uses the following named ranges:<br />

Name<br />

Month<br />

Product<br />

Table<br />

MonthList<br />

ProductList<br />

Refers To<br />

B1<br />

B2<br />

D1:H14<br />

D1:D14<br />

D1:H1<br />

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

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

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 with the<br />

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 />

TIP<br />

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

You can use the Lookup wizard add-in to create this type of formula. The Lookup wizard addin<br />

is distributed with Excel. When this add-in is installed, access it by choosing Formulas ➪<br />

Solutions ➪ Lookup.<br />

TIP<br />

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

of the table. A quick way to do so is to select the table and choose Formulas ➪ Defined<br />

Names ➪ Create From Selection. In the Create Names From Selection dialog box, select the Top Row and<br />

Left Column check boxes. After creating the names, you can use a simple formula, such as:<br />

= Sprockets July<br />

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

Chapter 11 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 15.13 shows an example.<br />

286

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

Saved successfully!

Ooh no, something went wrong!