Skip to main content
1-Visitor
Feb 5, 2015 12:15 AM UTC
Solved

How to search a Matrix for a number bounded by another number?

In the attached Prime worksheet is it possible to create a function that can search the second row of the matrix for the a number closest but higher than ZxREQ while also making sure that it's corresponding value in the first row is between dmax and din? The issue I'm having is how do you search in a particular row in a matrix?

Werner_E
Werner_EAnswer
25-Diamond I
Feb 5, 2015 2:12 AM UTC

Changed the sample data

Simplified the first method.

Changed all methods to use <= rsp. >=

Added a third, tricky method

2.png

17 replies

Werner_E
25-Diamond I
Feb 5, 2015 12:26 AM UTC

From the file you posted it looks like you are searching a value in the second column, not in the second row.

BTW, what should the outpit of that function be? A list(vector) of indices as Match would return? The first value of the second column which fits? A vector of all values of the second column which fit? The samllest value in the second column that fits? ...

Translate
dsochor1-VisitorAuthor
1-Visitor
Feb 5, 2015 12:38 AM UTC

You're right, I did mean the second column.

The function would output the corresponding value in a third column which I will add.

Translate
Werner_E
25-Diamond I
Feb 5, 2015 12:47 AM UTC

Then you should setup a sheet with complete data!

So the value in the second column should be > (or >= ) ZxREQ?

The value in the first column should be between d.min and d,max. Usually this would exclude values equal to d.min or dmax. Is that correct?

The output cant be just a value but rather a vector of corresponding values from the third column as it may not be only a single value which fulfills tghe conditions.

Translate
Werner_E
25-Diamond I
Feb 5, 2015 1:08 AM UTC

Here are two different ways of achieving what you demanded so far (no error checking implemented so far):

1.png

Translate
Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
Feb 5, 2015 2:12 AM UTC

Changed the sample data

Simplified the first method.

Changed all methods to use <= rsp. >=

Added a third, tricky method

2.png

Translate
dsochor1-VisitorAuthor
1-Visitor
Feb 6, 2015 5:37 PM UTC

Thank you for your help Werner, is it possible to create a vlookup that looks in a specified column, not just the first column?

Translate