Skip to main content
1-Visitor
February 5, 2015
Solved

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

  • February 5, 2015
  • 17 replies
  • 7404 views

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?

Best answer by Werner_E

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
February 5, 2015

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? ...

dsochor1-VisitorAuthor
1-Visitor
February 5, 2015

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

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

Werner_E
25-Diamond I
February 5, 2015

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.

Werner_E
25-Diamond I
February 5, 2015

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

1.png

Werner_E
Werner_E25-Diamond IAnswer
25-Diamond I
February 5, 2015

Changed the sample data

Simplified the first method.

Changed all methods to use <= rsp. >=

Added a third, tricky method

2.png

dsochor1-VisitorAuthor
1-Visitor
February 6, 2015

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