When inserting rows, you need to start from the bottom and work up.
Try this.
Sub Get_r_Done()
Dim sh As Worksheet, lr As Long, i As Long, x As Long, rng As Range, cel As Range, a, b, c, d
Set sh = Sheets(1) 'Edit sheet name
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
With sh
If .Cells(i, 7).Value = .Cells(i - 1, 7).Value Then
x = x + 1
Else
Set rng = .Cells(i, 4).Resize(x + 1, 1)
Set cel = .Cells(i, 4).Offset(x + 1, 0)
cel.EntireRow.Insert
If rng.Count > 1 Then
a = Application.Sum(rng)
b = Application.Sum(rng.Offset(, 1))
c = IIf(a = 0, b, a)
d = IIf(a = 0, 1, 0)
cel.Offset(-1#, d) = c
cel.EntireRow.Insert
x = 0
End If
End If
End With
Next
End Sub
Bookmarks