#### dal777

##### New Member
Hi all,I'm in need of some help. As you can see from the image below I need a function/s in D4 that will total ( in this case ) B3 to B7. Because the lists vary in the number of rows a simple SUM(B3:B7) which I could copy and paste will not work, what I need is a more dynamic formula which will work out how many rows it should sum, when A=1 that is the last row that should be added to the sum. By the way is doesnt matter what values - if any end up in the D column cells except where C=0, hope that makes sense.
I will want to copy / paste the formula in D3 all the way down the D column.

The cells are colour coded for easier identifcation - a new colour is a new list

I'd been trying to work this out for a while but just cant figure it out so any help / suggestions would really be apprciated - thanks.

Click to see a sample of the sheet: http://img.photobucket.com/albums/v732/dal777/excel.jpg

Edited by Von Pookie ~ picture was kind of large

### Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

##### Active Member
If Sum

Dal777
Try this in D3:
=IF(C3=0,"",SUM(B3:B21))
Double click the fill handle to copy down the remaining cells.
or
=IF(C3=0,"",SUM(\$B\$3:\$B\$21))
if the column B range remains the same rows 3 to 21

Hope this is what your after
Paul

#### barry houdini

##### MrExcel MVP
Try in D3 copied down

=IF(C3<>0,"",SUM(B3:INDEX(B3:B\$100,MATCH(1,A3:A\$100,0))))

Change 100 for a higher number if your data goes further

#### dal777

##### New Member
Barry - Yes it works, nice one, thanks , I'd never had have been able to figure that one out on my own, I'll now be able to sort a huge amount of data- thank you.

Regards.

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,163,990
Messages
5,834,761
Members
430,318
Latest member
ZackChua95

### 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.

### Which adblocker are you using?

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

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