Sub test()
Dim r As Range, lastrow As Integer, c As Range
lastrow = Range("A1").CurrentRegion.SpecialCells(xlCellTypeLastCell).Row
Set r = Range("C1:F1")
For Each c In r
Cells(lastrow + 1, c.Column) = WorksheetFunction.Sum(Range(Cells(2, c.Column), Cells(lastrow, c.Column)))
Next c
End Sub
Sub testone()
Dim r As Range
'Range("C1048576").End(xlUp).Offset(2, 0).Select
Set r = Cells(Rows.Count, "C").End(xlUp).Offset(2, 0)
'Selection.FormulaR1C1 = "=SUM(R1c3:r[-2]C)"
r.FormulaR1C1 = "=SUM(R1c3:r[-2]C)"
'Selection.Style = "comma"
'Selection.Borders(xlDiagonalDown).LineStyle = xlNone
'Selection.Borders(xlDiagonalUp).LineStyle = xlNone
'Selection.Borders(xlEdgeLeft).LineStyle = xlNone
'With Selection.Borders(xlEdgeTop)
'.LineStyle = xlContinuous
'.ColorIndex = 0
'.TintAndShade = 0
'.Weight = xlThin
'End With
'With Selection.Borders(xlEdgeBottom)
'.LineStyle = xlDouble
'.ColorIndex = 0
'.TintAndShade = 0
'.Weight = xlThick
r.NumberFormat = "0,000.00"
r.Copy Range(r.Offset(0, 1), r.Offset(0, 3))
End Sub
Sub testTWO()
Dim r As Range, lastrow As Integer, c As Range, myformula
lastrow = Range("A1").End(xlDown).Row
Set r = Cells(lastrow + 2, "C")
Do
r.Formula = "=sum(" & r.Offset(-2, 0).Address & ":" & Cells(1, r.Column).Address & ")"
r.NumberFormat = "#,##0.00"
Set r = r.Offset(0, 1)
If r.Column > Range("F1").Column Then Exit Do
Loop
End Sub
DON'T MISS