ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert Rows after text appears in column (https://www.excelbanter.com/excel-programming/307030-insert-rows-after-text-appears-column.html)

Kenny

Insert Rows after text appears in column
 
I'd like to insert four rows after certain text appears in
a column.

Any ideas?

TIA

Tom Ogilvy

Insert Rows after text appears in column
 
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


--
Regards,
Tom Ogilvy

"KENNY" wrote in message
...
I'd like to insert four rows after certain text appears in
a column.

Any ideas?

TIA




Soo Cheon Jheong[_2_]

Insert Rows after text appears in column
 
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
_ _
^вп^
--



Kenny

Insert Rows after text appears in column
 
Thanks for responding... If I could bother you for a bit
mo

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



-----Original Message-----
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


--
Regards,
Tom Ogilvy

"KENNY" wrote in

message
...
I'd like to insert four rows after certain text appears

in
a column.

Any ideas?

TIA



.


Tom Ogilvy

Insert Rows after text appears in column
 
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
"KENNY" wrote in message
...
Thanks for responding... If I could bother you for a bit
mo

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



-----Original Message-----
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


--
Regards,
Tom Ogilvy

"KENNY" wrote in

message
...
I'd like to insert four rows after certain text appears

in
a column.

Any ideas?

TIA



.





All times are GMT +1. The time now is 05:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com