Sub Add_Rows()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 2 Step -1
If Cells(i, 1) = "D" Then
Rows(i).Insert
Rows(i - 2).Copy Rows(i)
End If
Next
End Sub
HTH
--
AP
"Ozzie via OfficeKB.com" <u18021@uwe a écrit dans le message de
news:5f5b6d83af8d8@uwe...
Apologies for the re-post but I originally posted this request into the
wrong
forum!
I need to insert a new row into a workbook where a character in Column "A"
=
"D" and then copy the row which is two rows above into the new inserted
row.
I can insert the row ok with the following code;
Sub Add_Rows()
Dim lastrow As Long, i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 2 Step -1
If Cells(i, 1) = "D" Then
Rows(i).Insert
End If
Next
End Sub
but what I can't do is copy the cells in 2 rows above this newly inserted
row?
.
I have been searching and reading numerous threads and links but to no
avail.
Can anyone assist?, i am using 2003.
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200604/1