Sub sumall() Dim wf As WorksheetFunction
Dim was As Worksheet
Set wf = Application.WorksheetFunction
Set ws = ActiveWorkbook.ActiveSheet
For I = 3 To 8 'selecting column C to column H
lastrow = Cells(Rows.Count, I).End(xlUp).Row 'finds the lastrow
Cells(lastrow + 1, I).Value = wf.Sum(Range(Cells(1, I), Cells(lastrow, I))) 'puts the sum on the first empty cell
If I = 7 Or I = 8 Then
Cells(lastrow + 1, I).Select
Selection.NumberFormat = "$#,##0.00"
End If
Next I
'This is the sort portion of the macro, from the macro recorder
ws.Sort.SortFields.Clear
ws.Sort.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ws.Sort
.SetRange Range("A1:H" & lastrow)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub