I see. I've modified the code to use a hardcoded start at 17, and cycle upwards to avoid the error.
Sub KittenExplosion()
Dim wsRev As Worksheet: Set wsRev = Sheets("Review")
Dim wsOver As Worksheet: Set wsOver = Sheets("Overpayment Summary")
Dim wsData As Worksheet: Set wsData = Sheets("Data")
Dim lngLastReview As Long: lngLastReview = wsRev.Range("J6").End(xlDown).Row
Dim i As Long, x As Long: x = 18
For i = 7 To lngLastReview
If wsRev.Cells(i, "P") < wsRev.Cells(i, "J") Then
wsOver.Range(wsOver.Cells(i, 1), wsOver.Cells(i, 10)).Copy
wsData.Range("A" & x).PasteSpecial xlPasteValues
wsData.Range("A" & x + 1).EntireRow.Insert Shift:=xlDown
With wsData.Range("A" & x + 1, "M" & x + 1)
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
End With
x = x + 1
End If
Next
End Sub
Bookmarks