Sumproduct from previously blank row

J

Jim

I would like to create a macro that will perform a sumproduct for all row
above where I start, up to the first cell after a blank row.

IE:

1: 2 | 4
2: 4 | 6
3:
4: 6 | 8
5: 10 | 12
6: Sumproduct=(A4:A5,B4:B5)

Where, A4:A5,B4:B5 could be any range UP to the next blank row.

Thanks
 
B

Bob Phillips

=SUM(A5:INDEX(A1:A5,MAX(IF(A1:A5="",ROW(A1:A5)))+1)*B5:INDEX(B1:B5,MAX(IF(A1:A5="",ROW(A1:A5)))+1))

which is an array formula, it should be committed with Ctrl-Shift-Enter, not
just Enter.
Excel will automatically enclose the formula in braces (curly brackets), do
not try to do this manually.
When editing the formula, it must again be array-entered.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
J

Jim

Hi Bob. Thanks for the reply. I want to be able to do this multiple times
across several row chunks. I guess I could be a bit more clear in my IE:

1: 2 | 4
2: 4 | 6
3: Sumproduct (A1:A2,B1:B2)
4:
5: 6 | 8
6: 4 | 7
7: 10 | 12
8: Sumproduct=(A5:A7,B5:B7)
Where row 8 sums rows above it to the point where there is a blank row and
where the arrays are different in number of rows.

Thanks!
Jim
 

Ask a Question

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.

Ask a Question

Top