Sum a Range : Excel Buildin Function « Excel « VBA / Excel / Access / Word






Sum a Range

 
Public Sub SumRangeTest()
  Dim aRange As Range
  
  With ActiveCell
    Set aRange = Range(.Offset(1), .Offset(1).End(xlDown))
    .Formula = "=SUM(" & aRange.Address(RowAbsolute:=False,ColumnAbsolute:=False) & ")"
    .Copy Destination:=Range(.Cells(1), .Offset(1).End(xlToRight).Offset(-1))
  End With
  
End Sub

 








Related examples in the same category

1.Use function from Excel
2.Payment Function:Pmt (interest, term, principal, future value, type)
3.Using Excel Application Functions in VBA
4.Cleans up every selected cell: with Proper function
5.Calculate a moving average
6.Call worksheet function directly