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.

Creating Formulas That Look Up Values 15<br />

FIGURE 15.15<br />

This workbook demonstrates how to perform a lookup by using the closest match.<br />

The array formula that follows identifies the closest match to the Target value in the Data range and returns<br />

the names of the corresponding student in column A (that is, the column with an offset of –1). The formula<br />

returns Leslie (with a matching value of 8,000, which is the one closest to the Target value of 8,025).<br />

{=INDIRECT(ADDRESS(ROW(Data)+MATCH(MIN(ABS(Target-Data)),<br />

ABS(Target-Data),0)-1,COLUMN(Data)+ColOffset))}<br />

If two values in the Data range are equidistant from the Target value, the formula uses the first one in<br />

the list.<br />

The value in ColOffset can be negative (for a column to the left of Data), positive (for a column to the right<br />

of Data), or 0 (for the actual closest match value in the Data range).<br />

To understand how this formula works, you need to understand the INDIRECT function. This function’s<br />

first argument is a text string in the form of a cell reference (or a reference to a cell that contains a text<br />

string). In this example, the text string is created by the ADDRESS function, which accepts a row and<br />

column reference and returns a cell address.<br />

289

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

Saved successfully!

Ooh no, something went wrong!