Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Alan Collins
 
Posts: n/a
Default I need help with LOOKUP

I need to find the closest match to the lookup_value. LOOKUP returns the
nearest match less than the lookup_value but this may not always be the
closest match. e.g. My lookup_value is 80, the column it is searching has
the following 55;68;81;86, LOOKUP will return results from the row which
contains 68. Obviously 81 is closer, can anyone suggest a way around this?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default I need help with LOOKUP

One way:

=MIN(IF(ABS(B1-A1:A4)=MIN(ABS(B1-A1:A4)),A1:A4))

With 80 in B1 and 55, 68, 81, 86 in A1:A4

This is an array formula. Hit ctrl-shift-enter instead of enter. If you do it
correctly, excel will wrap curly brackets {} around your formula. (don't type
them yourself.)

Adjust the range to match--but you can't use the whole column.


Alan Collins wrote:

I need to find the closest match to the lookup_value. LOOKUP returns the
nearest match less than the lookup_value but this may not always be the
closest match. e.g. My lookup_value is 80, the column it is searching has
the following 55;68;81;86, LOOKUP will return results from the row which
contains 68. Obviously 81 is closer, can anyone suggest a way around this?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Alan Collins
 
Posts: n/a
Default I need help with LOOKUP

Sorry, I didn't make myself clear. The lookup_value is variable so are the
figures in the lookup-vector. The results in the result_vector column are
fixed. If my Lookup_value is 80 I want the closest possible match in the
lookup_vector column regardless of whether it is slightly higher than the
lookup_value. Unfotunately the lookup function always matches to a lower
value if it cannot find an exact match. This can result in too much of an
error.

"Dave Peterson" wrote:

One way:

=MIN(IF(ABS(B1-A1:A4)=MIN(ABS(B1-A1:A4)),A1:A4))

With 80 in B1 and 55, 68, 81, 86 in A1:A4

This is an array formula. Hit ctrl-shift-enter instead of enter. If you do it
correctly, excel will wrap curly brackets {} around your formula. (don't type
them yourself.)

Adjust the range to match--but you can't use the whole column.


Alan Collins wrote:

I need to find the closest match to the lookup_value. LOOKUP returns the
nearest match less than the lookup_value but this may not always be the
closest match. e.g. My lookup_value is 80, the column it is searching has
the following 55;68;81;86, LOOKUP will return results from the row which
contains 68. Obviously 81 is closer, can anyone suggest a way around this?


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default I need help with LOOKUP

What did you get when you tried that formula?

Alan Collins wrote:

Sorry, I didn't make myself clear. The lookup_value is variable so are the
figures in the lookup-vector. The results in the result_vector column are
fixed. If my Lookup_value is 80 I want the closest possible match in the
lookup_vector column regardless of whether it is slightly higher than the
lookup_value. Unfotunately the lookup function always matches to a lower
value if it cannot find an exact match. This can result in too much of an
error.

"Dave Peterson" wrote:

One way:

=MIN(IF(ABS(B1-A1:A4)=MIN(ABS(B1-A1:A4)),A1:A4))

With 80 in B1 and 55, 68, 81, 86 in A1:A4

This is an array formula. Hit ctrl-shift-enter instead of enter. If you do it
correctly, excel will wrap curly brackets {} around your formula. (don't type
them yourself.)

Adjust the range to match--but you can't use the whole column.


Alan Collins wrote:

I need to find the closest match to the lookup_value. LOOKUP returns the
nearest match less than the lookup_value but this may not always be the
closest match. e.g. My lookup_value is 80, the column it is searching has
the following 55;68;81;86, LOOKUP will return results from the row which
contains 68. Obviously 81 is closer, can anyone suggest a way around this?


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
RagDyeR
 
Posts: n/a
Default I need help with LOOKUP

Try this *array* formula with your lookup value entered in D1:

=INDEX(B1:B10,MATCH(MIN(ABS(A1:A10-D1)),ABS(A1:A10-D1),0))

--
Array formulas are entered using CSE, <Ctrl <Shift <Enter, instead of the
regular <Enter, which will *automatically* enclose the formula in curly
brackets, which *cannot* be done manually.

--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===

"Alan Collins" wrote in message
...
Sorry, I didn't make myself clear. The lookup_value is variable so are the
figures in the lookup-vector. The results in the result_vector column are
fixed. If my Lookup_value is 80 I want the closest possible match in the
lookup_vector column regardless of whether it is slightly higher than the
lookup_value. Unfotunately the lookup function always matches to a lower
value if it cannot find an exact match. This can result in too much of an
error.

"Dave Peterson" wrote:

One way:

=MIN(IF(ABS(B1-A1:A4)=MIN(ABS(B1-A1:A4)),A1:A4))

With 80 in B1 and 55, 68, 81, 86 in A1:A4

This is an array formula. Hit ctrl-shift-enter instead of enter. If you

do it
correctly, excel will wrap curly brackets {} around your formula. (don't

type
them yourself.)

Adjust the range to match--but you can't use the whole column.


Alan Collins wrote:

I need to find the closest match to the lookup_value. LOOKUP returns

the
nearest match less than the lookup_value but this may not always be the
closest match. e.g. My lookup_value is 80, the column it is searching

has
the following 55;68;81;86, LOOKUP will return results from the row which
contains 68. Obviously 81 is closer, can anyone suggest a way around

this?

--

Dave Peterson



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another way to lookup data David Vollmer Excel Worksheet Functions 1 September 23rd 05 05:16 AM
Lookup function help marlea Excel Worksheet Functions 4 August 30th 05 08:11 PM
Lookup Vector > Lookup Value Alec Kolundzic Excel Worksheet Functions 6 June 10th 05 02:14 PM
Lookup function w/Text and Year Josh O. Excel Worksheet Functions 1 February 12th 05 11:27 PM
double lookup, nest, or macro? Josef.angel Excel Worksheet Functions 1 October 29th 04 09:50 AM


All times are GMT +1. The time now is 08:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"