ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting corresponding test value to a MIN function (https://www.excelbanter.com/excel-programming/343506-getting-corresponding-test-value-min-function.html)

confused_chris

Getting corresponding test value to a MIN function
 
I have a sheet that looks something like this...

Supplier Price Low Price Supplier Low Price
Jimmy's Widgets 10 7
Widget World 45
Widget Discount 7
Widget's R Us 35565

I am able to get "7" to come up as my low price with this function...
=MIN(B2:B5) but I want the name of the corresponding supplier to appear under
"Low Price Supplier". I have tried various combinations of IF, MATCH, etc.
with no success.

Help Please!!

Thanks,

Chris the excel peon

Kleev

Getting corresponding test value to a MIN function
 
Here is one way to do it (maybe not the best, but it worked for my test:)
Create a function like so:
Function myLookup(myInt As Integer, myRng As Range) As String
For Each cell In myRng
If myInt = cell.Value Then
myLookup = cell.Offset(, -1).Value
Exit For
End If
Next cell
End Function
And then in the worksheet, enter a formula like so:
=mylookup(D1,B1:B4) where d1 is the low price value you are looking up and
b1:b4 is where the Price is. Change types as necessary (from the data given,
it looked like Integer would work for the test.) Or if you were looking for
max, you could change it to long.


"confused_chris" wrote:

I have a sheet that looks something like this...

Supplier Price Low Price Supplier Low Price
Jimmy's Widgets 10 7
Widget World 45
Widget Discount 7
Widget's R Us 35565

I am able to get "7" to come up as my low price with this function...
=MIN(B2:B5) but I want the name of the corresponding supplier to appear under
"Low Price Supplier". I have tried various combinations of IF, MATCH, etc.
with no success.

Help Please!!

Thanks,

Chris the excel peon


Dave Peterson

Getting corresponding test value to a MIN function
 
=index(a2:a5,match(min(b2:b5),b2:b5,0))



confused_chris wrote:

I have a sheet that looks something like this...

Supplier Price Low Price Supplier Low Price
Jimmy's Widgets 10 7
Widget World 45
Widget Discount 7
Widget's R Us 35565

I am able to get "7" to come up as my low price with this function...
=MIN(B2:B5) but I want the name of the corresponding supplier to appear under
"Low Price Supplier". I have tried various combinations of IF, MATCH, etc.
with no success.

Help Please!!

Thanks,

Chris the excel peon


--

Dave Peterson

confused_chris[_2_]

Getting corresponding test value to a MIN function
 
Hey Dave,

Thanks - you're the man! I was a little confused by the first reply but
yours works out very nicely!

Cheers,

"no longer" Confused Chirs



"Dave Peterson" wrote:

=index(a2:a5,match(min(b2:b5),b2:b5,0))



confused_chris wrote:

I have a sheet that looks something like this...

Supplier Price Low Price Supplier Low Price
Jimmy's Widgets 10 7
Widget World 45
Widget Discount 7
Widget's R Us 35565

I am able to get "7" to come up as my low price with this function...
=MIN(B2:B5) but I want the name of the corresponding supplier to appear under
"Low Price Supplier". I have tried various combinations of IF, MATCH, etc.
with no success.

Help Please!!

Thanks,

Chris the excel peon


--

Dave Peterson



All times are GMT +1. The time now is 02:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com