insert formula in bottom blank cell to subtotal upto blank cell

smeetony1

New Member
Joined
May 29, 2018
Messages
4
Hi all

I have a worksheet containing thousands of numbers dates and times. All of which I have separated by inserting blank row after time value change.

I now need the blank row to subtotal the cells between the two blanks. The number of cells is not the same between any
of the blanks.

Is there a solution?

Thanks in anticipation.

Tony
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I can give you a VBA solution if you tell me what column you want the subtotals in...
 
Upvote 0
I will add a sample of the chart. I would need the subtotal to follow through in the blank cells. Up to the blank cell above.

[TABLE="width: 810"]
<tbody>[TR]
[TD]Sat[/TD]
[TD]10:22[/TD]
[TD]19/05/2018[/TD]
[TD]0.00[/TD]
[TD]0.92[/TD]
[TD]0.67[/TD]
[TD]8.22[/TD]
[TD]0.38[/TD]
[/TR]
[TR]
[TD]Mon[/TD]
[TD]10:22[/TD]
[TD]21/05/2018[/TD]
[TD]0.00[/TD]
[TD]1.68[/TD]
[TD]1.22[/TD]
[TD]7.27[/TD]
[TD]0.00[/TD]
[/TR]
[TR]
[TD]SUB[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Sun[/TD]
[TD]10:25[/TD]
[TD]01/04/2018[/TD]
[TD]0.00[/TD]
[TD]2.50[/TD]
[TD]1.43[/TD]
[TD]8.23[/TD]
[TD]0.02[/TD]
[/TR]
[TR]
[TD]Mon[/TD]
[TD]10:25[/TD]
[TD]02/04/2018[/TD]
[TD]0.00[/TD]
[TD]1.13[/TD]
[TD]0.37[/TD]
[TD]7.42[/TD]
[TD]0.00[/TD]
[/TR]
[TR]
[TD]Sun[/TD]
[TD]10:25[/TD]
[TD]08/04/2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sun[/TD]
[TD]10:25[/TD]
[TD]15/04/2018[/TD]
[TD]0.00[/TD]
[TD]0.87[/TD]
[TD]0.43[/TD]
[TD]6.50[/TD]
[TD]0.00[/TD]
[/TR]
[TR]
[TD]Sun[/TD]
[TD]10:25[/TD]
[TD]22/04/2018[/TD]
[TD]0.00[/TD]
[TD]0.97[/TD]
[TD]1.37[/TD]
[TD]7.33[/TD]
[TD]0.00[/TD]
[/TR]
[TR]
[TD]Sun[/TD]
[TD]10:25[/TD]
[TD]29/04/2018[/TD]
[TD]0.00[/TD]
[TD]4.87[/TD]
[TD]3.95[/TD]
[TD]5.87[/TD]
[TD]0.00[/TD]
[/TR]
[TR]
[TD]Sun[/TD]
[TD]10:25[/TD]
[TD]06/05/2018[/TD]
[TD]0.00[/TD]
[TD]2.23[/TD]
[TD]1.22[/TD]
[TD]6.62[/TD]
[TD]0.77[/TD]
[/TR]
[TR]
[TD]Mon[/TD]
[TD]10:25[/TD]
[TD]07/05/2018[/TD]
[TD]0.00[/TD]
[TD]0.75[/TD]
[TD]2.38[/TD]
[TD]9.52[/TD]
[TD]0.00[/TD]
[/TR]
[TR]
[TD]Sun[/TD]
[TD]10:25[/TD]
[TD]13/05/2018[/TD]
[TD]0.00[/TD]
[TD]5.60[/TD]
[TD]5.08[/TD]
[TD]6.22[/TD]
[TD]0.03[/TD]
[/TR]
[TR]
[TD]SUB[/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[TD] [/TD]
[/TR]
[TR]
[TD]Sat[/TD]
[TD]11:22[/TD]
[TD]31/03/2018[/TD]
[TD]0.00[/TD]
[TD]2.07[/TD]
[TD]1.65[/TD]
[TD]8.40[/TD]
[TD]0.00[/TD]
[/TR]
[TR]
[TD]Wed[/TD]
[TD]11:22[/TD]
[TD]04/04/2018[/TD]
[TD]0.00[/TD]
[TD]1.92[/TD]
[TD]1.15[/TD]
[TD]6.85[/TD]
[TD]0.00[/TD]
[/TR]
</tbody><colgroup><col><col><col><col span="5"></colgroup>[/TABLE]


Thanks
 
Upvote 0
Am I reading correctly, you want the subtotals in Columns D, E, F, G, H.
 
Upvote 0
Does this do what you want.

Code:
Sub GetSubs5()


    Dim subt As Double
    Dim TopofSection As Long, lastrow As Long
    
    Application.ScreenUpdating = False
    lastrow = Cells(Rows.Count, "B").End(xlUp).Row
    Do Until lastrow < 2
        TopofSection = Cells(lastrow, "B").End(xlUp).Row
        If Cells(lastrow - 1, 2) = "" Then TopofSection = lastrow
        subt = WorksheetFunction.Sum(Range("D" & TopofSection, "D" & lastrow))
        Range("D" & lastrow).Offset(1, 0).Value = subt
        subt = WorksheetFunction.Sum(Range("E" & TopofSection, "E" & lastrow))
        Range("E" & lastrow).Offset(1, 0).Value = subt
        subt = WorksheetFunction.Sum(Range("F" & TopofSection, "F" & lastrow))
        Range("F" & lastrow).Offset(1, 0).Value = subt
        subt = WorksheetFunction.Sum(Range("G" & TopofSection, "G" & lastrow))
        Range("G" & lastrow).Offset(1, 0).Value = subt
        subt = WorksheetFunction.Sum(Range("H" & TopofSection, "H" & lastrow))
        Range("H" & lastrow).Offset(1, 0).Value = subt
        lastrow = Cells(TopofSection, 2).End(xlUp).Row
    Loop
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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