Lookup matched value or next in sequence

GAJITCS

Board Regular
Joined
Apr 21, 2015
Messages
66
I had this sorted yesterday, but too much clicking of the Undo and lost it.

I have two numbers in cells F5 and F6 and need to match the higher value to a list, displaying either the match or if not matched, the next value in sequence.


FGHIJ
50.375
60.5
7
80.250.501.002.003.00

<tbody>
</tbody>

In this case, searching for the result of max(F5:F6) should return a value of 0.50 from range F8:J8.


FGHIJ
50.625
60.50
7
80.250.501.002.003.00

<tbody>
</tbody>

But in this case, searching for the result of max(F5:F6) should return the value of 1.00 from range F8:J8.

Should the result of max(F5:F6) be greater than J8, I need to trap it as an error.

Yesterdays solution was so simple.

Many thanks.
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try

=AGGREGATE(15,6,F8:J8/(F8:J8>=MAX(F5:F6)),1)
 
Upvote 0
Thank you both.

Aladin, I couldn't get yours to return the correct value when F5 had a value of 0.625. It still returned 0.5 and not 1.00

Peter, Your's works well and is now in use, but I don't understand it. If you have the time, could you explain it please.
 
Upvote 0
Peter, Your's works well and is now in use, but I don't understand it. If you have the time, could you explain it please.
Good news (the first part). :)

In English, the formula finds the smallest number (=AGGREGATE(15, ...) in F8:J8 that is greater than or equal to the maximum of F5:F6. Given that F8:J8 are in ascending order that finds either the exact match or the next number in the sequence - which was your stated requirement.

You can get some more information & examples regarding the AGGREGATE function here.
 
Upvote 0
Thank you both.

Aladin, I couldn't get yours to return the correct value when F5 had a value of 0.625. It still returned 0.5 and not 1.00

Peter, Your's works well and is now in use, but I don't understand it. If you have the time, could you explain it please.

The range F8:J8 is sorted in ascending order, so I assumed LOOKUP tout court is exactly what is needed. It appears an additional step is needed.


In F7 enter:

=MAX(F5:F6)

Now run:

=IF(F7>J8,"error",INDEX(F8:J8,MATCH(F7,F8:J8,1)+(LOOKUP(F7,F8:J8)) < F7)))

This doesn't involve any array-processing.
 
Upvote 0
=IF(F7>J8,"error",INDEX(F8:J8,MATCH(F7,F8:J8,1)+(LOOKUP(F7,F8:J8)) < F7)))

This doesn't involve any array-processing.
The formula is not valid
When corrected, it is not robust against small values in F5:F6
There is no problem with array-processing here.
 
Upvote 0
The formula is not valid

A misplaced paren. A great hit.

When corrected, it is not robust against small values in F5:F6

I don't see any specification involving F7 < MIN(F5:F6), so an Excel error value would not be inadequate.

There is no problem with array-processing here.

And again, the MATCH+KOOKUP formula does not involve array-processing.

Edit for the misplaced paren:

=IF(F7>J8,"error",INDEX(F8:J8,MATCH(F7,F8:J8,1)+(LOOKUP(F7,F8:J8) < F7)))
 
Upvote 0

Forum statistics

Threads
1,215,424
Messages
6,124,817
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top