Also mine corrected:
Sub test()
Dim i As Long, j As Long, k As Long, current As Long, cell As Range, prefix As String
Application.ScreenUpdating = False
For k = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
Set cell = Cells(k, 1)
current = Val(IIf(InStr(cell, "-"), Right(cell, Len(cell) - InStrRev(cell, "-")), cell))
prefix = Replace(cell, current, "")
j = Val(cell.Offset(0, 1))
If j > 0 Then
cell.Offset(1, 0).Resize(j, 1).EntireRow.Insert
For i = 1 To j
current = current + 1
Cells(k + j, 1) = IIf(Len(prefix), prefix & current, current)
Next i
End If
Next k
End Sub
Slower one, but could be (who knows ) a bit easier to understand
Bookmarks