Google Exceltip.com
Account Icon
Shopping Cart
CheckOut

» Retrieving the Closest Larger and Closest Smaller Values from a List When There Is No Exact Match

Problem:

Listed in B2:B5 are values to look up in column A.
We want to create formulas to look up each value and, in the case of there being no exact match, return the closest larger and the colsest smaller number that is in the list.

Solution:

To find the closest larger number or an exact match in column A, use the SMALL and COUNTIF functions as shown in the following formula:
=SMALL($A$2:$A$7,COUNTIF($A$2:$A$7,""<""&B2)+1)

To find the closest smaller number or an exact match in column A, use the LARGE and COUNTIF functions as shown in the following formula:
=LARGE($A$2:$A$7,COUNTIF($A$2:$A$7,"">""&B2)+1)


Example:

List1
2
5
4
10
1
6

Value to look______Closest larger value____Closest smaller value
3__________________4_______________________2
5__________________5_______________________5
7__________________10______________________6
9__________________10______________________6
Screenshot // Retrieving the Closest Larger and Closest Smaller Values from a List When There Is No Exact Match

Retrieving the Closest Larger and Closest Smaller Values from a List When There Is No Exact Match
Rate this tip
12 34 5
  RATING: 3.67
  VIEWS: 10202
  No comments have been submitted.


REGISTERED USERS click here to post comments


GUESTSclick here to Register
Name
Comment Title
Comments


Terms and Conditions of use
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Copyright © 2003 ExcelTip.com
Microsoft, Microsoft Excel is a U.S. registered trademark of Microsoft Corporation