?
Solved

lookup next highest value

Posted on 2013-11-01
6
Medium Priority
?
323 Views
Last Modified: 2013-11-01
Hi
I want to be able to enter a value in a cell and then have a formula that will lookup a value in a range - easy enough. But if the value I enter is between two of the lookup numbers then I want it to return the value associated with the larger of the numbers.
e.g.
Length     Size
100           10
125            12
150            15

Enter a Length of 100 and VLookup will return a size of 10
If I enter a Length of 110 I want it to return a size of 12.


Help greatly received
Andy
0
Comment
Question by:ieg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 39616488
Hi

pls use

=INDEX(B2:B4,MATCH(D2,A2:A4,-1))

Open in new window


but your data has to be in descending order
MatchIndex.xlsx
Regards
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 39616492
Hi Andy,

I can achieve the result using INDEX, MATCH, & LOOKUP.

If the sample data above is in the range [A1:B4], so that cell [A1] is "Length" & [B1] is "Size", & the data starts on row 2, & the value to be queried is in cell [E3], then this is the "VLOOKUP" formula that may be placed in any other cell to return the appropriate "Size":

=IF(E3<A2,B2,INDEX(B2:B4,MATCH(E3,A2:A4,1)+(LOOKUP(E3,A2:A4)<E3)))

Within the attached workbook, this formula is in cell [E4].

Note that a value less than 100 (cell [A2]) returns [B2], but a value greater than 150 (cell [A4]) will return #REF!.

BFN,

fp.
Q-28282930.xls
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 2000 total points
ID: 39616578
You can use this formula with INDEX and MATCH, assuming lookup value in E3 as per fp's setup

=INDEX(B2:B4,MATCH(TRUE,INDEX(A2:A4>=E3,0),0))

If there is no equal or higher value you get #N/A

The second INDEX function isn't strictly necessary - I included it so that you don't need to "array enter" the formula. This version will work too

=INDEX(B2:B4,MATCH(TRUE,A2:A4>=E3,0))

confirmed with CTRL+SHIFT+ENTER

regards, barry
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:ieg
ID: 39616632
Thanks to you all - I've accepted Barry's "array formula" answer because it is the neatest
I just need to do some work to stop the #N/A if I select a number out of the range.
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 39616653
Assuming Excel 2007 or later you can add an IFERROR function to deal with #N/A, e.g.

=IFERROR(INDEX(B2:B4,MATCH(TRUE,A2:A4>=E3,0)),"No match")

regards, barry
0
 

Author Comment

by:ieg
ID: 39616658
Many thanks - works a treat
Andy
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question