Page 320 - Excel 2007 Bible
P. 320
20_044039 ch15.qxp 11/21/06 11:07 AM Page 277
Creating Formulas That Look Up Values
the function uses the row in which the value you want to look up is greater than or equal to the row value
but less than the value in the next row. In the case of a tax table, this is exactly what you want to happen.
The HLOOKUP function
The HLOOKUP function works just like the VLOOKUP function except that the lookup table is arranged hori-
zontally instead of vertically. The HLOOKUP function looks up the value in the first row of the lookup table
and returns the corresponding value in a specified table row.
The syntax for the HLOOKUP function is
HLOOKUP(lookup_value,table_array,row_index_num,range_lookup)
The HLOOKUP function’s arguments are as follows
n lookup_value: The value to be looked up in the first row of the lookup table.
n table_array: The range that contains the lookup table.
n row_index_num: The row number within the table from which the matching value is returned.
n range_lookup: Optional. If TRUE or omitted, an approximate match is returned. (If an exact
match is not found, the next largest value less than lookup_value is returned.) If FALSE, VLOOKUP
will search for an exact match. If VLOOKUP can’t find an exact match, the function returns #N/A. 15
TIP If the lookup_value argument is text, it can include wildcard characters * and ?.
TIP
Figure 15.3 shows the tax rate example with a horizontal lookup table (in the range E1:J3). The formula in
cell B3 is
=HLOOKUP(B2,E1:J3,3)
FIGURE 15.3
Using HLOOKUP to look up a tax rate.
The LOOKUP function
The LOOKUP function has the following syntax:
LOOKUP(lookup_value,lookup_vector,result_vector)
The function’s arguments are as follows:
n lookup_value: The value to be looked up in the lookup_vector.
n lookup_vector: A single-column or single-row range that contains the values to be looked up.
These values must be in ascending order.
n result_vector: The single-column or single-row range that contains the values to be returned.
It must be the same size as the lookup_vector.
277