Lowest value in range of cells excluding this row

RobOrBob

New Member
Joined
Aug 4, 2023
Messages
41
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have a range of cells that contain negative and positive values plus 0.

I am trying to return for each row the minimum value in the range including only those > 0 and excluding the current row.

I have managed a solution by returning the minimum value before the current row and that after the current row. But its horrible :)

Screenshot 2024-03-22 210315.png


lastRow (aka G1): 11 =MAX((A:A<>"")*(ROW(A:A)))
Col A = values
Col B = lowest non-zero value before this row
Col C = lowest non-zero value after this row
Col D = lowest non-zero value of col C and Col D

arrVals: =Sheet1!$A$1:INDEX(Sheet1!$A$1:$A$50,lastRow)
Cell B1: =LET(minbefore,INDEX(arrVals,1):INDEX(arrVals,ROW()-1),IF(ROW()=1,0,MINIFS(minbefore,minbefore,">0")))
Cell C1: =LET(minafter,INDEX(arrVals,ROW()+1):INDEX(arrVals,lastRow),IF(ROW()=lastRow,0,MINIFS(minafter,minafter,">0")))
Cell D1: =MINIFS(B1:C1,B1:C1,">0")

Any help appreciated!

Note:
The cells cannot be converted to a table.
There will be 1 to 50 values.
A value may be duplicated (including the minimum value).
It must use a formula and not VBA.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
What about doing them all at once with this in the top cell only, no need to copy down? (Also MINIFS generally more efficient than FILTER)

24 03 23.xlsm
AB
11.550.82
20.880.82
32.550.82
400.82
500.82
6-1.80.82
7-1.550.82
80.820.83
91.550.82
1000.82
110.830.82
MINIFS
Cell Formulas
RangeFormula
B1:B11B1=LET(r,A1:A11,MINIFS(r,r,">0",r,"<>"&r))
Dynamic array formulas.
 
Upvote 0
Hi Peter

Thanks for the reply.

That also works but has the same issue as Cubist's solution in that it excludes all values that match the current row values.
A value may be duplicated (including the minimum value). So, if the current row value is the minimum and that same value occurs on another row then the other rows value should return as the minimum and not also excluded.

But both solutions have certainly given me a boost!
 
Upvote 0
You didn't indicate this requirement in the prior posts.
 
Upvote 0
Adding a column with a unique identifier for each row (arrSels) seems to have resolved it (need to fully test it)
=LET(r,arrVals,s,arrSels,MINIFS(r,r,">0",s,"<>"&s))

Thanks for your input.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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