add a row after every unique number

K

Kirk

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

Thanks,
Kirk
 
M

Mike H

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
 
M

Mike H

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
 
I

Insert row and duplicate titles

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top