Page 321 - Excel 2007 Bible
P. 321

20_044039 ch15.qxp  11/21/06  11:07 AM  Page 278
                                   Part II
                                              Working with Formulas and Functions
                                             The LOOKUP function looks in a one-row or one-column range (lookup_vector) for a value (lookup_value)
                                             and returns a value from the same position in a second one-row or one-column range (result_vector).
                                                       Values in the lookup_vector must be in ascending order. If lookup_value is smaller than the
                                        CAUTION
                                        CAUTION
                                                       smallest value in lookup_vector, LOOKUP returns #N/A.
                                             Figure 15.4 shows the tax table again. This time, the formula in cell B3 uses the LOOKUP function to return
                                             the corresponding tax rate. The formula in cell B3 is
                                                  =LOOKUP(B2,D2:D7,F2:F7)
                                                       If the values in the first column are not arranged in ascending order, the LOOKUP function may
                                        CAUTION
                                        CAUTION
                                                       return an incorrect value.
                                             Note that LOOKUP (as opposed to VLOOKUP) requires two range references (a range to be looked in, and a
                                             range that contains result values). VLOOKUP, on the other hand, uses a single range for the lookup table,
                                             and the third argument determines which column to use for the result. This argument, of course, can con-
                                             sist of a cell reference.
                                       FIGURE 15.4
                                      Using LOOKUP to look up a tax rate.
                                             Combining the MATCH and INDEX functions
                                             The MATCH and INDEX functions are often used together to perform lookups. The MATCH function returns
                                             the relative position of a cell in a range that matches a specified value. The syntax for MATCH is
                                                  MATCH(lookup_value,lookup_array,match_type)
                                             The MATCH function’s arguments are as follows:
                                                 n lookup_value: The value you want to match in lookup_array. If match_type is 0 and the
                                                    lookup_value is text, this argument can include wildcard characters “*” and “?”
                                                 n lookup_array: The range being searched.
                                                 n match_type: An integer (–1, 0, or 1) that specifies how the match is determined.
                                          NOTE         If match_type is 1, MATCH finds the largest value less than or equal to lookup_value.
                                           NOTE
                                                       (lookup_array must be in ascending order.) If match_type is 0, MATCH finds the first value
                                             exactly equal to lookup_value. If match_type is –1, MATCH finds the smallest value greater than or equal
                                             to lookup_value. (lookup_array must be in descending order.) If you omit the match_type argument, this
                                             argument is assumed to be 1.



                                      278
   316   317   318   319   320   321   322   323   324   325   326