Insert 5 Rows above Specific Text

Andy15

Board Regular
Joined
Apr 1, 2017
Messages
56
Hi all,

I am looking to find the text "Final" in column B and insert 5 entire rows above it.

Thanks for any help
Andy
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
How about
Code:
Sub Final()
   Dim fnd As Range
   Set fnd = Range("B:B").find("final", , xlValues, xlWhole, , , False, , False)
   If Not fnd Is Nothing Then fnd.EntireRow.Resize(5).Insert
End Sub
 
Upvote 0
Try this:
Code:
Sub My_Find()
'Modified  8/10/2018  5:01:51 PM  EDT
Dim SearchString As String
Dim SearchRange As Range
Dim Lastrow As Long
Dim r As Long
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
SearchString = "Final"
Set SearchRange = Range("B1:B" & Lastrow).Find(SearchString, LookIn:=xlValues, lookat:=xlWhole)
If SearchRange Is Nothing Then MsgBox SearchString & "  Not foud": Exit Sub
r = SearchRange.Row
Rows(r).Resize(5).Insert shift:=xlUp
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top