Hello azegurb,
This macro will size your range based on the last entry in column "A". It will then loop through each cell and apply the calculations.
Sub initialize()
Dim Cell As Range
Dim Rng As Range
Dim RngEnd As Range
Dim Wks As Worksheet
Set Wks = Worksheets(1)
Set Rng = Wks.Range("A2")
Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
Set Rng = IIf(RngEnd.Row < Rng.Row, Rng, Wks.Range(Rng, RngEnd))
For Each Cell In Rng
If Cell.Offset(0, 1) > Cell Then
Cell.Offset(0, 2) = Cell.Offset(0, 1) - Cell
Cell.Offset(0, 3) = ""
End If
If Cell > Cell.Offset(0, 1) Then
Cell.Offset(0, 3) = Cell - Cell.Offset(0, 1)
Cell.Offset(0, 2) = ""
End If
Next Cell
End Sub
Bookmarks