Search code examples
excelif-statementexcel-formulavlookuplookup

Is there a way to return value from an array if it is between two numbers?


Is there a way to fill in column B if the value in column A is between the numbers in column D and E? If the value is 41 then I want to return N/A since 41 is not in the range of numbers. Everything I tried just filled "Grape" since it was the closest and I don't want a long IF statement.

Data


Solution

  • Lookup Value If Number Between Two Numbers

    =LOOKUP(2,1/((A1>=$D$1:$D$5)*(A1<=$E$1:$E$5)),$F$1:$F$5)
    

    IF you change your mind and don't wanna show #N/A then you can improve with e.g.

    =IFERROR(LOOKUP(2,1/((A1>=$D$1:$D$5)*(A1<=$E$1:$E$5)),$F$1:$F$5),"")