ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro to insert row after specific text (https://www.excelbanter.com/excel-discussion-misc-queries/46059-macro-insert-row-after-specific-text.html)

Luke

macro to insert row after specific text
 
in column "A" I need to insert row after specific word, "First Out". is
there a macro for this?
I have over 7000 rows and one at a time is not good.
Thank you
Luke




Bob Phillips

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "A").Value = "First Out" Then
Rows(i + 1).Insert
End If
Next i

End Sub


--
HTH

Bob Phillips

"Luke" wrote in message
...
in column "A" I need to insert row after specific word, "First Out". is
there a macro for this?
I have over 7000 rows and one at a time is not good.
Thank you
Luke






Luke

Thank you Bob
Luke

"Bob Phillips" wrote:

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "A").Value = "First Out" Then
Rows(i + 1).Insert
End If
Next i

End Sub


--
HTH

Bob Phillips

"Luke" wrote in message
...
in column "A" I need to insert row after specific word, "First Out". is
there a macro for this?
I have over 7000 rows and one at a time is not good.
Thank you
Luke








All times are GMT +1. The time now is 06:11 AM.

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