GregTampa

excel fill in the gap

Aug 28th, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. Sub test_v2()
  2. Dim i As Long, j As Long
  3. i = Cells(Rows.Count, "A").End(xlUp).Row
  4. Application.ScreenUpdating = False
  5. For j = i To 1 Step -1
  6. If Cells(j + 1, 1) <> "" Then
  7. If Cells(j + 1, 1).Value - Cells(j, 1).Value > 1 Then
  8. x = Cells(j + 1, 1).Value - Cells(j, 1).Value
  9. Rows(j + 1 & ":" & x + j - 1).Insert
  10. End If
  11. End If
  12. Next j
  13. With Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
  14. .Formula = "=Row()"
  15. .Value = .Value
  16. End With
  17. Application.ScreenUpdating = True
  18. End Sub
Advertisement
Add Comment
Please, Sign In to add comment