18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Part II<br />

Working with Formulas and Functions<br />

The LOOKUP function looks in a one-row or one-column range (lookup_vector) for a value (lookup_value)<br />

and returns a value from the same position in a second one-row or one-column range (result_vector).<br />

CAUTION<br />

Values in the lookup_vector must be in ascending order. If lookup_value is smaller than the<br />

smallest value in lookup_vector, LOOKUP returns #N/A.<br />

Figure 15.4 shows the tax table again. This time, the formula in cell B3 uses the LOOKUP function to return<br />

the corresponding tax rate. The formula in cell B3 is<br />

=LOOKUP(B2,D2:D7,F2:F7)<br />

CAUTION<br />

If the values in the first column are not arranged in ascending order, the LOOKUP function may<br />

return an incorrect value.<br />

Note that LOOKUP (as opposed to VLOOKUP) requires two range references (a range to be looked in, and a<br />

range that contains result values). VLOOKUP, on the other hand, uses a single range for the lookup table,<br />

and the third argument determines which column to use for the result. This argument, of course, can consist<br />

of a cell reference.<br />

FIGURE 15.4<br />

Using LOOKUP to look up a tax rate.<br />

Combining the MATCH and INDEX functions<br />

The MATCH and INDEX functions are often used together to perform lookups. The MATCH function returns<br />

the relative position of a cell in a range that matches a specified value. The syntax for MATCH is<br />

MATCH(lookup_value,lookup_array,match_type)<br />

The MATCH function’s arguments are as follows:<br />

n<br />

n<br />

n<br />

lookup_value: The value you want to match in lookup_array. If match_type is 0 and the<br />

lookup_value is text, this argument can include wildcard characters “*” and “?”<br />

lookup_array: The range being searched.<br />

match_type: An integer (–1, 0, or 1) that specifies how the match is determined.<br />

If match_type is 1, MATCH finds the largest value less than or equal to lookup_value.<br />

NOTE<br />

(lookup_array must be in ascending order.) If match_type is 0, MATCH finds the first value<br />

exactly equal to lookup_value. If match_type is –1, MATCH finds the smallest value greater than or equal<br />

to lookup_value. (lookup_array must be in descending order.) If you omit the match_type argument, this<br />

argument is assumed to be 1.<br />

278

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

Saved successfully!

Ooh no, something went wrong!