Macro for column sum
Sub SelectFirstToLastInColumn()
Dim TopCell, BottomCell, x
Set TopCell = Cells(1, ActiveCell.Column)
Set BottomCell = Cells(16384, ActiveCell.Column)
If IsEmpty(TopCell) Then Set TopCell = TopCell.End(xlDown)
If IsEmpty(BottomCell) Then Set BottomCell = BottomCell.End(xlUp)
If TopCell.Row = 16384 And BottomCell.Row = 1 Then ActiveCell.Select
Else Range(TopCell, BottomCell).Select
x = Selection.Address
Cells(BottomCell.Row + 1, ActiveCell.Column).Select
ActiveCell.Formula = "=sum(" & x & ")"
End Sub
|