A
anon
Actually.....this regular formula is quite a bit shorter than my previous
one....
D1:
=MAX(INDEX(SUBTOTAL(9,OFFSET(A1,ROW($A$1:INDEX(A:A,ROWS(A1:A20)-C1+1))-1,,6,)),0))
or...for the ARRAY FORMULA version (committed with ctrl+shift+enter):
D1: =MAX(SUBTOTAL(9,OFFSET(A1,ROW($A$1:INDEX(A:A,ROWS(A1:A20)-C1+1))-1,,6,)))
Where cell C1 contains the number of cells you want aggregated and tested.
In your example, C1: 6
Is that something you can work with?
Yes, indeed. I think both formulas have a "6" in them which should be
C1, right?
On my machine, both formulas work either as regular or as array
formulas.
I would really like to understand the formula, so I've taken it apart,
bit by bit to try to do so. But I have failed. :-((
If anybody wants to take a stab at explaining it to me, I would
appreciate it.
I am now generally familiar with the help topics on SUBTOTAL, OFFSET
and INDEX, but something tells me that I don't understand their
nuances very well.
I think I want to work with the array formula because I may need to
drive this array (A1:A20) with a multiplier, where the multiplier
might be zero and, most importantly, where if the multiplier is zero,
the cell drops out of the calculation. I know I'm asking for a lot,
especially since I don't (yet) understand the underlying formula, but
I thought I'd lay out where I now know I (eventually) need to get to.
For example, using the same data, but changed ever so slightly:
A1:8
A2:10
A3:87
A4:100
A5:40
A6:50
A7:39
A8:100
A9:299
A10:0
A11:150
A12:18
A13:93
A14:30
A15:10
A16:40
A17:4
A18:70
A19:9
A20:149
I have dropped A10 to zero (meaning it should have no impact on the
calculations) and therefore really have a 20 item array rather than a
21 item array. I have increased A11 to 150 so that it would be part
of the 6 highest that runs from A5:A11 (skipping A10 entirely). The
six highest are now 678.
I suspect that if I understood the array formula, I could make this
work (eventually). Then again, I might be wrong and the introduction
of this latest wrinkle might mean that I have to go the VBA route.
Can it be done in a cell formula?
Thanks
Jim