Assuming that after every SECTION there will be a cell in column A named TOTAL, this code should do the trick

Code:Sub Macro1() Dim LR As Long: LR = Range("A" & Rows.Count).End(xlUp).Row For i = 1 To LR If Trim(Range("A" & i).Value) = "TOTAL" Then Range("C" & i).Formula = "=SUM(C" & i - 1 & ":C" & Range("C" & i - 1).End(xlUp).Row & ")" End If Next i End Sub

## Like this thread? Share it with others