View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.newusers
George
 
Posts: n/a
Default vlookup-Closest value

atatari wrote:
Dear Friends,

How can I use Vlookup to give me the closest value greather than or equal to
vlookup value.For example if my lookup value is 5 and I have 4.9 and 5.1,5.2
It chooses 5.1 and give me the corresponding value.

Thank you,


VLOOKUP(lookup_value,table_array,col_index_num,ran ge_lookup)

The default behaviour of Vlookup will;
basically assign everything between (and including) 4.9 and less than
5.1 to the 4.9 value. So 4.9 <= x < 5.1
So the value 5 will actually get hooked up with the 4.9 value which does
not appear to be what you want.

Try using MATCH and INDEX, this is just one work around.
Sort your values in reverse order eg.
Col A, Col B
5.2 AnswerFor5.2
5.1 AnswerFor5.1
4.9 AnswerFor4.9

So the answer you are after is =INDEX(B1:B3,MATCH(5,A1:A3,-1))
This will return "AnswerFor5.1"

The -1 tells us to look in descending instead of ascending order.
And you can change the number 5 to point to a cell you wish to look up.
With this method Columns A and B don't even have to be next to each
other. B1:B3 could quite easily have been column Z eg. 'Z1:Z3' or even
in the same column A eg. 'A11:A13'

Hope this helps
George