I need to write an Excel Macro that sums up the values of the cells above in a certain column, e.g. column "C". The first Row is always 5 but the number of rows that comes below that is varying. The code needs to select the cell in the last row and then sum up the values above, e.g. (=SUM(C5:C?)) in that cell.
Here is what I already have from code but I have trouble specifiying the second last cell in the column, which is the last cell that is going to be included in the sum:
With ThisWorkbook
Set wsDestination = .Worksheets("Overview")
End With
FirstRow = Rows(5).EntireRow
lastRow = wsDestination.Cells(Rows.Count, "C").End(xlUp).Row
Worksheets("Overview").Select
wsDestination.Cells(lastRow, "C").Select
ActiveCell.Formula = "=SUM(FirstRowC:(C& LastRow).Offset(-1,0))"
Can someone explain to me how to specify this? Thanks