Use min or max dynamically from a cell in formula in another cell

tanvirabid3

New Member
Joined
Oct 15, 2021
Messages
13
Office Version
  1. 365
Platform
  1. Windows
I want to find the minimum or maximum from a range. I want to choose min or max on a dynamic basis. This means that if my reference value is above 0, I want to use maximum. If my reference value is below 0, I want to use minimum. I have this formula =IF(M6>0,"max","min"). In the next cell, I am trying to use max or min and apply it on a referenced range. How can I do this without having to manually put max or min. Thanks for your help.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Perhaps I'm missing something but don't you just want something like this?

Excel Formula:
=IF(M6>0,MAX(N2:N8),MIN(N2:N8))
 
Upvote 0
Perhaps I'm missing something but don't you just want something like this?

Excel Formula:
=IF(M6>0,MAX(N2:N8),MIN(N2:N8))

Hi Peter, the formula is good. Actually, I did not explain clearly what I am trying to do. Please see the image. If the reference value is below 0, I want the lowest five values. If the reference value is above zero, I am looking for the top five values. I have tried to build on your formula in cell B25. But there are errors. Please take a look.
 

Attachments

  • min max picture.PNG
    min max picture.PNG
    36.6 KB · Views: 18
Upvote 0
I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with. :)

See if this helps.

23 07 16.xlsm
ABC
3Ref-11
4
5
611
755
822
966
1044
1188
1255
1399
1444
1577
16
17
1819
1928
2047
2146
2255
23
Top Bottom
Cell Formulas
RangeFormula
B18:C22B18=TAKE(SORT(B6:B15,,-SIGN(B3)),5)
Dynamic array formulas.
 
Upvote 0
I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with. :)

See if this helps.

23 07 16.xlsm
ABC
3Ref-11
4
5
611
755
822
966
1044
1188
1255
1399
1444
1577
16
17
1819
1928
2047
2146
2255
23
Top Bottom
Cell Formulas
RangeFormula
B18:C22B18=TAKE(SORT(B6:B15,,-SIGN(B3)),5)
Dynamic array formulas.
Hi Peter, actually I couldn't use the formula because the take and sort functions don't work on my version of excel. I tried the following:

=IF(B$3>0,LARGE(B$6:B$15,$A6),IF(B$3<0,SMALL(B$6:B$15,$A6)))

A6 has the value of 1, A7 of 2 and so on. As I drag down, it gives me the values on an ascending or descending basis (subject to the reference value being below or above zero).

Please validate. But I think it works. Thank you.
 
Upvote 0
the take and sort functions don't work on my version of excel.
Do you actually have MS365 as shown in your profile? If so, I would have thought that you would at least have the SORT function?
Have you looked to apply any available updates?
 
Upvote 0
Actually I now have Microsoft Office Professional Plus 2013, Thanks Peter for your help.
 
Upvote 0
Actually I now have Microsoft Office Professional Plus 2013,
In that case you probably should fix your account details?

1689597741330.png


Here is another option to consider

23 07 16.xlsm
ABC
3Ref-18
4
5
611
755
822
966
1044
1188
1255
1399
1444
1577
16
17
1819
1928
2047
2146
2255
Top Bottom (2)
Cell Formulas
RangeFormula
B18:C22B18=AGGREGATE(IF(B$3>0,14,15),6,B$6:B$15,ROWS(B$18:B18))
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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