A member named Jim May offered some great code to add missing rows in a sequence.
However, the code gets lost if there is a duplicate row.
Would anyone know the code modification. Example:
row 1 John A
row 2 Jane b+
Jim's original code:
*******************************************
Sub Foo()
Dim FNumb As Long, TNumb As Long
Lr = Range("A" & Rows.Count).End(xlUp).Row
TNumb = Range("A" & Lr).Value
Range("A1").Select
FNumb = Selection.Value
Do Until ActiveCell.Value = TNumb
If ActiveCell.Offset(1) = (FNumb + 1) Then
Else
ActiveCell.Offset(1).EntireRow.Insert
End If
FNumb = FNumb + 1
ActiveCell.Offset(1).Select
Loop
End Sub
*******************************************
However, the code gets lost if there is a duplicate row.
Would anyone know the code modification. Example:
row 1 John A
row 2 Jane b+
Jim's original code:
*******************************************
Sub Foo()
Dim FNumb As Long, TNumb As Long
Lr = Range("A" & Rows.Count).End(xlUp).Row
TNumb = Range("A" & Lr).Value
Range("A1").Select
FNumb = Selection.Value
Do Until ActiveCell.Value = TNumb
If ActiveCell.Offset(1) = (FNumb + 1) Then
Else
ActiveCell.Offset(1).EntireRow.Insert
End If
FNumb = FNumb + 1
ActiveCell.Offset(1).Select
Loop
End Sub
*******************************************