Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

My current code is:

(SUM(INDIRECT(ADDRESS(ROW()-(I4:I- 1);COLUMN()-4;4)&":"&ADDRESS(ROW();COLUMN()-4;4)))*( ( J4:J ) / 10 ))))

I want to sum cells from GxGy but range is determed by cell I4. My existing code works, but only for one line.

=ArrayFormula( if( J4:J = "" ; "" ;

So if I put ArrayFormula in front, the calculation is shown only where the data is, but the result is always equal to the result of first row.

Can anyone help me?

You can view my sheet here.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

With the magic of matrix multiplication and this solution (credit where credit is due), I have managed to wrangle it to do what you want.

=ArrayFormula(IF( J4:J = "" ; "" ; MMULT((ROW(G4:G)>=TRANSPOSE(ROW(G3:G)))*((ROW(G4:G)+1-I4:I)<=TRANSPOSE(ROW(G3:G)));G3:G)* ( ( J4:J ) / 10 ) ))

My head hurts already, so I won't go into too much explanatory detail, except to say that the key magic happens in

="MMULT((ROW(Range1)>=TRANSPOSE(ROW(Range2)))*((ROW(Range1)+1-I4:I)<=TRANSPOSE(ROW(Range2)));Range2)))"

And I've added a second sheet to your public one with a rough equation builder, for understanding or alternative applications.

share|improve this answer
1  
Thank you!!! If You will ever visit Bled, text me and i will buy you at least a beer :) –  Miha Avgustin Oct 8 '13 at 9:31
1  
You're welcome. And I'll make you deliver on that offer one day. –  Tom Horwood Oct 8 '13 at 10:35
    
you are welcome :) –  Miha Avgustin Oct 9 '13 at 9:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.