MrExcel Publishing
Your One Stop for Excel Tips & Solutions

insert row variation

Posted by Andonny on December 21, 2000 11:39 AM

The code below inserts a row below JE if there is a blank cell. How do I change the code if I want to insert a row two cells underneath JE.

Dim i As Long, j As Long
j = Range(Range("A1"), Range("A65536").End(xlUp)).Count
For i = j To 2 Step -1
If Cells(i, 1) = "" And Cells(i, 1).Offset(-1, 0) = "JE" Then

Cells(i, 1).EntireRow.Insert
Cells(i, 2) = "XX"
End If
Next i
End Sub

Thanks once again for your kind help

Posted by Celia on December 21, 2000 2:25 PM

Cells(i, 1).EntireRow.Insert Cells(i, 2) = "XX"

Cells(i + 1, 1).EntireRow.Insert

Posted by Andonny on December 22, 2000 1:35 AM

Thanks a million Celia !