To add row after 24 rows and get the sum

Solved/Closed
Report
-
 RIZVISA1 -
Hello,
I have hourly data of one year in rows without any break. I want to add row after 24 hrs and get the sum of all the coumns in that row. In other words I wand to get the sum of daily data form hourly data
THANKS

1 reply

with presumption that the data starts from A2 and is limited to column A

Dim lRowFactor As Integer
Dim lStart24HourRow As Integer
Dim lEnd24HourRow As Long

lStart24HourRow = 2
lRowFactor = 24


Do While Cells(lStart24HourRow, 1) <> ""

lEnd24HourRow = lStart24HourRow + lRowFactor

Rows(lEnd24HourRow).Insert

With Cells(lEnd24HourRow, 1)

.FormulaR1C1 = "=SUM(R" & lStart24HourRow & "C : R" & lEnd24HourRow - 1 & "C)"
.Font.Bold = True

End With

lStart24HourRow = lEnd24HourRow + 1

Loop
2
Thank you

A few words of thanks would be greatly appreciated. Add comment

CCM 2821 users have said thank you to us this month