If you wanted the values only and not the IF formulas then
Sub NewLoop()
Dim Rg As Range
'there may be no blank cells
On Error Resume Next
'Find all cells in column B that have a corresponding blank cell in column E in the usedrange
Set Rg = Intersect(Range("E:E"), ActiveSheet.UsedRange, Cells.SpecialCells(xlCellTypeBlanks)).Offset(0, -3)
On Error GoTo 0
'Add the formula to the B cells and the XX to E cells
If Not Rg Is Nothing Then
Rg.FormulaR1C1 = "=IF(RC[-1]=R[-1]C[-1],R[-1]C+RC[1],RC[1])"
Rg.Formula = Rg.Value
Rg.Offset(0, 3) = "XX"
End If
End Sub
Cheers
Dave