Hi,
Try this code which I've commented to help you understand what's happening:
Public Sub FillBlankRows()
Dim colSum(1) As Double
Dim lastRow As Long
Dim thisRow As Long
Dim thisCol As Long
' Find the last row
lastRow = Cells(Rows.Count, "A").End(xlUp).Row
' Set the current column sums to zero
colSum(0) = 0
colSum(1) = 0
' Process all rows
For thisRow = 2 To lastRow
' Process both columns
For thisCol = 1 To 2
' Is this row blank?
If Cells(thisRow, thisCol).Value = "" Then
' Yes - put in the running total and reset the total to zero
Cells(thisRow, thisCol).Value = colSum(thisCol - 1)
colSum(thisCol - 1) = 0
Else
' No - add this column value to the running total
colSum(thisCol - 1) = colSum(thisCol - 1) + Cells(thisRow, thisCol).Value
End If
Next thisCol
Next thisRow
End Sub
WBD
Bookmarks