Insert Rows after text appears in column

T

Tom Ogilvy

Sub insert4()
dim lastrow as long, i as long
lastrow = cells(rows.count,1).End(xlup)
for i = lastrow to 1 step - 1
if cells(i,1).Value = "certain text" then
cells(i,1).offset(1,0).resize(4).Entirerow.Insert
end if
Next

End Sub
 
S

Soo Cheon Jheong

Hi,

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Option Explicit
Sub insert_Rows()

Dim R As Long
Dim i As Long

R = Cells(Rows.Count, 1).End(xlUp).Row

For i = R To 1 Step -1
If UCase(Cells(i, 1).Value) = "CERTAIN TEXT" Then
If Application.CountA(Cells(i + 1, 1).Resize(4)) > 0 Then
Cells(i + 1, 1).Resize(4).EntireRow.Insert
End If
End If
Next

End Sub
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


--
Regards,
Soo Cheon Jheong
_ _
^¢¯^
--
 
K

KENNY

Thanks for responding... If I could bother you for a bit
more:

1. To make it more efficient, I just need it to look
through column G

2. The text I'm looking for is actually the last three
letters of the text that appears in that column (Right, 3).

If I'm not over-stepping, could you help?

TIA
 
T

Tom Ogilvy

Sub insert4()
dim lastrow as long, i as long
lastrow = cells(rows.count,"G").End(xlup)
for i = lastrow to 1 step - 1
if right(lcase(cells(i,"G").Value),3) = lcase("abc") then
cells(i,1).offset(1,0).resize(4).Entirerow.Insert
end if
Next

--
Regards,
Tom Ogilvy



End Sub
 
Top