Search code examples
excelindexingexcel-formulaformulaarray-formulas

Formula to Find if Number is between a Range in 2 Columns and then Pick 1st Column, or 2nd if Empty


There are 4 columns. 1st column has the result, 2nd column has a backup result if the 1st column is empty, the 3rd column has the low/floor value of range, and the 4th column has the high/ceiling value of range.

The Excel formula should check and see what row the search value sits in between columns 3 and 4, and then pulls column 1 if a value is found, or pulls column 2.

| 1st Column |  2nd Column|3rd Column ||3rd Column |
|------------|------------|-----------|------------|
| a          |az1         |    1      |        5   |
| b          |az2         |    6      |        10   |
| c          |az3         |    11     |        15   |
| -           |az4         |    16     |        20   |

Search Value 1: 13
Result: c

Search Value 2: 6
Result: b

Search Value 3: 19
Result: az4

Thank you in Advance for help and guidance!!


Solution

  • Try this formula for the all Excel versions.

    In G2, enter formula :

    =LOOKUP(F2,C2:C5,IF({0;0;0;1},B2:B5,A2:A5))
    

    enter image description here