I use a macro in an excel which identifies duplicates and inserts a row before the duplicate values, the trouble am facing is the macro only identifies upto 2 duplicates and inserts a row for every 2 duplicates. So if I had 6 duplicates, it would insert
a row after every 2 duplicates. I need it group a set of duplicates, Can someone help me modify the macro in such a way that it works for a n duplicate value?
Option Explicit
Sub Insert_Row()
Dim LASTROW As Long
Dim I As Long
LASTROW = Range("A" & Rows.Count).End(xlUp).Row
For I = LASTROW + 1 To 1 Step -1
If ((Cells(I, "A") = Cells(I + 1, "A")) And (Cells(I, "A") <> "")) Then
Rows(I).Insert
End If
Next I
End Sub