VB Code:
Option Explicit
Sub AutoSumSheet()
Dim ColHeaders() As Range
Dim cell As Variant
Dim i As Long
ReDim ColHeaders(0)
For Each cell In Range("A1", Cells(1, Columns.Count).End(xlToLeft))
If cell = "TotalScheduledItems" Or cell = "NotSampled" Then
ReDim Preserve ColHeaders(UBound(ColHeaders) + i)
Set ColHeaders(i) = cell
i = i + 1
End If
Next cell
Set cell = Cells.SpecialCells(xlCellTypeLastCell)
cell.Offset(3, -2) = "Total Points"
cell.Offset(4, -2) = "Total Missed"
For i = LBound(ColHeaders) To UBound(ColHeaders)
If ColHeaders(i) = "TotalScheduledItems" Then
cell.Offset(3, -1).Formula = "=Sum(" & Cells(ColHeaders(i).Row + 1, ColHeaders(i).Column).AddressLocal(0, 0) & _
":" & Range(ColHeaders(i).Address).End(xlDown).AddressLocal(0, 0) & ")"
ElseIf ColHeaders(i) = "NotSampled" Then
cell.Offset(4, -1).Formula = "=Sum(" & Cells(ColHeaders(i).Row + 1, ColHeaders(i).Column).AddressLocal(0, 0) & _
":" & Range(ColHeaders(i).Address).End(xlDown).AddressLocal(0, 0) & ")"
End If
Next
End Sub
Notice in the sample workbook I made the last column have a different amount of rows in it and the formulas are set up to only sum how many rows are being used in that particular column.