Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Editing VB Code with VB | Excel Programming | |||
Insert Character into Editing-Cell | Excel Programming | |||
stubborn Excel crash when editing code with code, one solution | Excel Programming | |||
Editing code | Excel Programming | |||
Help with some code to insert rows | Excel Programming |