Applying Autosum multiple times in one column with varying numbers of lines

Jerry138889

New Member
Joined
May 23, 2013
Messages
28
Hi.

I have a set of data where I have to add in multiple subtotals but I can't use the subtotal function for a couple of reasons.

Basically I have data like this:


10
20
15
10
10
11
11
10
15
20
35
50
15
15
15

<tbody>
</tbody>


And everywhere there is a gap I want to add a subtotal so that it only adds the figures between the two gaps. For example, if I filled out the above example as I would like it, I would get:

10
20
15
45
10
10
11
11
10
52
15
20
35
50
120
15
15
15
15
30

<tbody>
</tbody>


When I manually click "Autosum" when I'm within the blank cells, autosum knows to only sum the cells that have not already been summed. I.e. for the last total which is 30, autosum knows to not sum all the items above - it just sums the last two.

My question is this - how do I use that same logic and apply it to all the blank cells at once instead of clicking autosum about 10,000 times like I did today.

Literally 10,000! I know there must be a way but I spent a solid hour googling and couldn't figure out how to phrase my query so as to find a solution as I'm sure this has been asked before.

Thank you very much.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try this:-
Code:
Dim Rng As Range, Dn As Range
Set Rng = Range("A:A").SpecialCells(xlCellTypeConstants)
For Each Dn In Rng.Areas
    Dn(Dn.Count + 1).Value = Application.Sum(Dn)
Next Dn
 
Upvote 0
Try this:-
Code:
Dim Rng As Range, Dn As Range
Set Rng = Range("A:A").SpecialCells(xlCellTypeConstants)
For Each Dn In Rng.Areas
    Dn(Dn.Count + 1).Value = Application.Sum(Dn)
Next Dn

Mick, you beautiful, beautiful man! Works like a charm!
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top