add a row after every unique number

  • Thread starter Thread starter Kirk
  • Start date Start date
K

Kirk

Is there a macro I could use to insert 16 rows after each change in value in
Column A?

Thanks,
Kirk
 
Hi,

Right click your sheet tab, view code and paste this and run it.

Sub insertrowifnamechg()
MyColumn = "A"
For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
If Cells(x - 1, MyColumn) <> Cells(x, MyColumn) Then
For i = 1 To 16
Rows(x).Insert
Next
End If
Next x
End Sub

Mike
 
On reflection, I prefer this method

Sub insertrowifnamechg()
MyColumn = "A"
For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
If Cells(x - 1, MyColumn) <> Cells(x, MyColumn) Then
Rows(x).Resize(16).Insert
End If
Next x
End Sub

Mike
 
Mike,
can you please tell me after inserting row how I can copy and paste the
headings or titles that I have on A1:P1 on every row that has been inserted.
Thank you in advance
RA
 
Back
Top