View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default How to determine the value?

Eric,

=INDEX(A1:A11,MATCH(FALSE,B1<A1:A11,0))

or if you want to return the larger value in the event of a tie

=INDEX(A1:A11,MATCH(MIN(ABS(A1:A11-B1)),ABS(A1:A11-B1),))

These are array formula which must be entered by pressing CTRL+Shift+Enter
and not just Enter. If you do it correctly then Excel will put curly brackets
around the formula {}. You can't type these yourself. If you edit the formula
you must enter it again with CTRL+Shift+Enter.


Mike


"Eric" wrote:

Does anyone have any suggestions on how to determine the closest number
without using sorting functions?

Example One
There is a list of number under column A
191,189,183,177,175,171,167,165,159,153,151
and there is a given number in cell B1, 154.
I would like to determine the closest number, which match with the number in
cell B1. On above example, it should return 153 in cell C1.

Example Two
There is a list of number under column A
191,189,183,177,175,171,167,165,155,153,151
and there is a given number in cell B1, 154.
I would like to determine the closest number, which match with the number in
cell B1. On above example, if the given number matches two numbers, which the
difference is the same, then it should return 153 in cell C1.
Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric