![]() |
add a row after every unique number
Is there a macro I could use to insert 16 rows after each change in value in
Column A? Thanks, Kirk |
add a row after every unique number
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 "Kirk" wrote: Is there a macro I could use to insert 16 rows after each change in value in Column A? Thanks, Kirk |
add a row after every unique number
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 H" wrote: 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 "Kirk" wrote: Is there a macro I could use to insert 16 rows after each change in value in Column A? Thanks, Kirk |
add a row after every unique number
Hey Mike,
That worked perfectly. Thanks for your help. Kirk "Mike H" wrote: 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 "Kirk" wrote: Is there a macro I could use to insert 16 rows after each change in value in Column A? Thanks, Kirk |
add a row after every unique number
Your welcome
"Kirk" wrote: Hey Mike, That worked perfectly. Thanks for your help. Kirk "Mike H" wrote: 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 "Kirk" wrote: Is there a macro I could use to insert 16 rows after each change in value in Column A? Thanks, Kirk |
add a row after every unique number
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 "Mike H" wrote: Your welcome "Kirk" wrote: Hey Mike, That worked perfectly. Thanks for your help. Kirk "Mike H" wrote: 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 "Kirk" wrote: Is there a macro I could use to insert 16 rows after each change in value in Column A? Thanks, Kirk |
All times are GMT +1. The time now is 01:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com