Quote Originally Posted by StephenR View Post
See if this starts you off - I'm just not clear about the start month
Sub x()

Dim r As Long, c As Long

Const n As Long = 160

Sheet2.Activate

For r = 2 To Cells(Rows.Count, 1).End(xlUp).Row
    c = 1
    Do While WorksheetFunction.Sum(Cells(r, 4).Resize(, c)) < Cells(r, 1)
        If Cells(r, 1) - WorksheetFunction.Sum(Cells(r, 4).Resize(, c)) < n Then
            Cells(r, 3 + c) = Cells(r, 1) - WorksheetFunction.Sum(Cells(r, 4).Resize(, c))
        Else
            Cells(r, 3 + c) = n
        End If
        c = c + 1
    Loop
Next r

End Sub
Thanks for your code, Stephan. It is not far from what I was looking for, but I would like to start in each row in the month of the date of the second column.

On the other hand, all blanks in the table should be zero numbers.

Thank you!