Inserting blank rows


Posted by Carole on July 13, 2001 1:37 PM

I have a spreadsheet with about 600 rows, and I need to insert a blank row when the values in column 1 and column 2 change.
Can someone help me to do this?

Posted by faster on July 13, 2001 1:49 PM

This should do it

Sub ZXY()
Range("A2").Select
Do While Selection <> ""
If Selection = Selection.Offset(-1, 0) Or Selection.Offset(0, 1) = Selection.Offset(-1, 1) Then
Selection.Offset(1, 0).Select
Else
Selection.EntireRow.Insert
Selection.Offset(2, 0).Select
End If
Loop
Range("A2").Select

End Sub

Posted by Carole on July 13, 2001 2:05 PM

Thanks! That was great!
Now I have something else to ask......
can END be put into the first column of each of those blank lines?

Posted by faster on July 16, 2001 9:12 AM

I think this is what you wanted.

Sub ZXY()
Range("A2").Select
Do While Selection <> ""
If Selection = Selection.Offset(-1, 0) Or Selection.Offset(0, 1) = Selection.Offset(-1, 1) Then
Selection.Offset(1, 0).Select
Else
Selection.EntireRow.Insert
ActiveCell = "END"
Selection.Offset(2, 0).Select
End If
Loop
ActiveCell = "END"
Range("A2").Select

End Sub



Posted by Carole on July 18, 2001 6:14 AM

Thanks so much!