11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

222<br />

Part II: Using Functions in Your <strong>Formula</strong>s<br />

Looking up a value to the left<br />

The VLOOKUP function always looks up a value in the first column of the lookup range. But what<br />

if you want to look up a value in a column other than the first column? It would be helpful if you<br />

could supply a negative value for the third argument for VLOOKUP — but you can’t.<br />

Figure 8-7 illustrates the problem. Suppose you want to look up the batting average (column B,<br />

in a range named Averages) of a player in column C (in a range named Players). The player you<br />

want data for appears in a cell named LookupValue. The VLOOKUP function won’t work because<br />

the data is not arranged correctly. One option is to rearrange your data, but sometimes that’s not<br />

possible.<br />

Figure 8-7: The VLOOKUP function can’t look up a value in column B, based on a value in column C.<br />

Another solution is to use the LOOKUP function, which requires two range arguments. The following<br />

formula (in cell F3) returns the batting average from column B of the player name contained<br />

in the cell named LookupValue:<br />

=LOOKUP(LookupValue,Players,Averages)<br />

Using the LOOKUP function requires that the lookup range (in this case, the Players range) is in<br />

ascending order. In addition to this limitation, the formula suffers from a slight problem: If you<br />

enter a nonexistent player (in other words, the LookupValue cell contains a value not found in the<br />

Players range), the formula returns an erroneous result.<br />

A better solution uses the INDEX and MATCH functions. The formula that follows works just like<br />

the previous one except that it returns #N/A if the player is not found. Another advantage to<br />

using this formula is that the player names need not be sorted.<br />

=INDEX(Averages,MATCH(LookupValue,Players,0))

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

Saved successfully!

Ooh no, something went wrong!