How to auto-sum groups of cells?

Helios9

Board Regular
Joined
Oct 15, 2006
Messages
127
Hello forum. I'm hoping someone out there can help me with this. I have a long column of numbers, all grouped into threes and fours, like this:

3
1
0

-6
-2
49

6
-50
-3
2

65
69
78
3

4
-1
-9
54

3
2
3
77

I'm looking for a way to way to auto-sum each group without having to do them individually. The result I'm looking for is like this:

3
1
0
4
-6
-2
49
41
6
-50
-3
2
-45
65
69
78
3
215
4
-1
-9
54
48
3
2
3
77
85

Thanks in advance.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Got it. Forgot to say "Range" once
Code:
Sub Autosum_all()
Dim TotalCell As Long, StartCell As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
    For i = lastrow + 1 To 1 Step -1
        If Cells(i, 1) = "" Then
            If TotalCell = 0 Then
                TotalCell = i
            Else
                StartCell = i
                Cells(TotalCell, 1) = Application.WorksheetFunction.Sum(Range(Cells(StartCell, 1), Cells(TotalCell - 1, 1)))
                TotalCell = StartCell
                StartCell = 0
            End If
        End If
    Next i
    Cells(TotalCell, 1) = Application.WorksheetFunction.Sum(Range(Cells(1, 1), Cells(TotalCell - 1, 1)))
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,882
Members
452,948
Latest member
Dupuhini

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