A
anon
Is there an easy way to extract the highest x (say, 6) consecutive
values from an array (say a1:a20)?
Thanks
Jim
values from an array (say a1:a20)?
Thanks
Jim
Is there an easy way to extract the highest x (say, 6) consecutive
values from an array (say a1:a20)?
Presumably you mean one at a time, or one per cell.
Care to explain what you exactly mean by "consecutive"?
You can enter this formula *anywhere*, and drag down to copy as many rows as
you wish to return the Nth largest values.
=LARGE(A1:A100,ROWS($1:1))
Try this:
Entered as an array using the key combination of CTRL,SHIFT,ENTER (not just
ENTER):
=MAX(SUBTOTAL(9,OFFSET(A1:A20,ROW(A1:A20)-MIN(ROW(A1:A20)),,6)))
Change the 6 to adjust the height as needed.
Based on your sample data returns 628
Care to explain what you exactly mean by "consecutive"?
You can enter this formula *anywhere*, and drag down to copy as many rows as
you wish to return the Nth largest values.
=LARGE(A1:A100,ROWS($1:1))
I want to have a formula which can take a value (n), which in this
case is 6, but might be another value at some point, and come out with
the sum of the n consecutive values which is the largest of all n
consecutive values.
Why not just sort the values first? Then it's a piece of cake with
e.g. =SUM(... INDIRECT ... ) ... )
Using the formula Ragdyer has written and with the amount of values in F1
(in your example 6) you can use this array-formula (Ctr+Shift+Enter)
=SUM(LARGE(--(A1:A100),ROW(INDIRECT("1:" & F1))))
It sums the 6 (F1) largest numbers and that is the same you asked for.
anon said:No, it is not what I asked for.
I need the 6 consecutive numbers which add up to the highest value.
Finding the 6 largest is trivial, whether I do a pre-sort or not. I
wish that was what I needed, but it isn't.
Jim
From Help ("About cell and range references", "The A1 reference style"
subtopic):
All cells in row 5 5:5
All cells in rows 5 through 10 5:10
All cells in column H H:H
All cells in columns H through J H:J
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?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.