How do I find a closest number in Excel and bring

2019-08-10 09:30发布

Row 1 : YORK / LEEDS / WINDSOR / CHESHIRE

Row 2 : 10 / 8 / 6 / 9

So I want to find the closest match to York in the other data across each row, and bring back the title of the closest match.

So the answer i want to bring back for row 2 (York = 10) is "CHESHIRE" as 9 is the closest to 10.

Thank you!

2条回答
Anthone
2楼-- · 2019-08-10 09:53

If your data is in A1:D2 try this "array formula"

=INDEX(B$1:D$1,MATCH(MIN(ABS(A2-B2:D2)),ABS(A2-B2:D2),0))

confirmed with CTRL+SHIFT+ENTER

If 2 or more values are equally close then the match will be with the first one from the left.....

查看更多
【Aperson】
3楼-- · 2019-08-10 09:53

There are reasons for avoiding array formulas, see e.g.:

If you care about this, and prefer not to use array formulas, the following works.

=INDEX(B$1:D$1,MATCH(MIN(INDEX(ABS($B2:$D2-$A2),0)),INDEX(ABS($B2:$D2-$A2),0),0))

Credits to Brad and barry houdini, who helped solving this question.

查看更多
登录 后发表回答