View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
DOR
 
Posts: n/a
Default Index Match function for multiple linked variables

Assuming data is in sheet1, on another sheet, in A1, put your target
value for column A (0 in the current example), and in B1 put your
target value for column B (3.14 in the example). In C1 of that sheet
put

=INDEX(Sheet1!F:F,MATCH(MIN(ABS(Sheet1!$A$1:$A$5-$A$1)+ABS(Sheet1!$B$1:$B$5-$B$1)),ABS(Sheet1!$A$1:$A$5-$A$1)+ABS(Sheet1!$B$1:$B$5-$B$1),0))

Enter as an array formula (ctl-shift-enter) and drag across across to
F. The values from the appropriate row in Sheet1 should appear.

This will find the minimum total absolute differences between the
target for A and column A, and the target for B and column B. If you
need to define "closest" any other way, a different approach may be
needed. For example, you could be looking for the smallest total
absolute percentage difference, or you could use least squares
differences, which would produce different results, and need a
different approach.

If you are prepared to use a helper column as others have suggested,
the formula can be greatly simplified and could easily be modified to
use different definitions of "closest", and it need not be an array
formula.

Hope this helps.

Declan O'R