I am trying to insert rows in between part numbers or job numbers on the attached spreadsheet. I am new to this forum and it seems really helpful. I have the following code, but unsuccessful. It would be awesome if someone could improve upon this code.
Sub InsertRowsV4()
Dim lLastRow As Long
Dim i As Long
Application.ScreenUpdating = False
lLastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = lLastRow - 1 To 2 Step -1
If Range("A" & i + 1).Value - Range("A" & i).Value > 0 Then
On Error Resume Next
Range("A" & i + 1).Resize(Range("A" & i + 1).Value - Range("A" & i).Value - 1, 1).EntireRow.Insert
On Error GoTo 0
End If
Next 'i
Application.ScreenUpdating = True
End Sub
Bookmarks