![]() |
Editing code to insert two rows
Excel Experts,
I have the following code that goes through a column of data in row C, starting from the bottom of the row, and inserts ONE blank row each time the data in cells in Column C changes. Sub InsertRow() For i = Cells(Rows.Count, "c").End(xlUp).Row To 1 Step -1 If Cells(i - 1, "c") < Cells(i, "c") Then Rows(i).Insert Next i End Sub How would I modify this code to insert TWO blank rows each time the data in column C changes. Thanks, Alan -- achidsey |
Editing code to insert two rows
Sub InsertRow()
For i = Cells(Rows.Count, "c").End(xlUp).Row To 2 Step -1 If Cells(i - 1, "c") < Cells(i, "c") Then Range(Rows(i), Rows(i).Offset(1, 0)).Rows.Insert Next i End Sub Kind Regards. "achidsey" (notmorespam), haber iletisinde şunları ... Excel Experts, I have the following code that goes through a column of data in row C, starting from the bottom of the row, and inserts ONE blank row each time the data in cells in Column C changes. Sub InsertRow() For i = Cells(Rows.Count, "c").End(xlUp).Row To 1 Step -1 If Cells(i - 1, "c") < Cells(i, "c") Then Rows(i).Insert Next i End Sub How would I modify this code to insert TWO blank rows each time the data in column C changes. Thanks, Alan -- achidsey |
Editing code to insert two rows
Try
Sub insertrows() For I = Cells(Rows.Count, "c").End(xlUp).Row To 2 Step -1 If Cells(I - 1, "c") < Cells(I, "c") Then Cells(I, "c").Resize(2, 1).EntireRow.Insert Next I End Sub -- Don Guillett SalesAid Software "achidsey" (notmorespam) wrote in message ... Excel Experts, I have the following code that goes through a column of data in row C, starting from the bottom of the row, and inserts ONE blank row each time the data in cells in Column C changes. Sub InsertRow() For i = Cells(Rows.Count, "c").End(xlUp).Row To 1 Step -1 If Cells(i - 1, "c") < Cells(i, "c") Then Rows(i).Insert Next i End Sub How would I modify this code to insert TWO blank rows each time the data in column C changes. Thanks, Alan -- achidsey |
All times are GMT +1. The time now is 05:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com