I am trying to set up a macro that will go down a column until the next empty row and then sum the rows above it. I have a macro right now that will accomplish this, but it only inserts the value not the actual equation itself. For example,
1
2
empty cell <---- find this empty cell and Sum the two rows above it (3)
3
4
5
6
empty cell <---- find this empty cell and Sum the 4 rows above it (18)
7
empty cell <---- find this empty cell and sum the row above it (7)
this is the macro I have so far....
Sub Fill()
Dim aArea As Range
For Each aArea In Columns("P").SpecialCells(xlCellTypeConstants).Areas
Cells(aArea.Row + aArea.Rows.Count, 16).Formula = WorksheetFunction.Min(Range(Cells(aArea.Row, 16), Cells(aArea.Row + aArea.Rows.Count - 1, 16)))
Cells(aArea.Row + aArea.Rows.Count, 22).Formula = WorksheetFunction.Sum(Range(Cells(aArea.Row, 22), Cells(aArea.Row + aArea.Rows.Count - 1, 22)))
Next aArea
End Sub
Thanks!
1
2
empty cell <---- find this empty cell and Sum the two rows above it (3)
3
4
5
6
empty cell <---- find this empty cell and Sum the 4 rows above it (18)
7
empty cell <---- find this empty cell and sum the row above it (7)
this is the macro I have so far....
Sub Fill()
Dim aArea As Range
For Each aArea In Columns("P").SpecialCells(xlCellTypeConstants).Areas
Cells(aArea.Row + aArea.Rows.Count, 16).Formula = WorksheetFunction.Min(Range(Cells(aArea.Row, 16), Cells(aArea.Row + aArea.Rows.Count - 1, 16)))
Cells(aArea.Row + aArea.Rows.Count, 22).Formula = WorksheetFunction.Sum(Range(Cells(aArea.Row, 22), Cells(aArea.Row + aArea.Rows.Count - 1, 22)))
Next aArea
End Sub
Thanks!