Insert Blank row before a specific term

Blessy Clara

Board Regular
Joined
Mar 28, 2010
Messages
193
The following code Inserts a blank row after a specific term

Sub insertRow()
Do
If InStr(1, Selection.Value, "Research director:") > 0 Then
Selection.Offset(1, 0).Select
Selection.EntireRow.Insert
End If
Selection.Offset(1, 0).Select
Loop While Selection.Value<> ""
End Sub

Could someone help me on how to modify the code to add a blank row BEFORE THE specific term - Thank you
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
9,055
Try:
Code:
Sub insertRow()
    Do
        If InStr(1, Selection.Value, "Research director:") > 0 Then
            Selection.EntireRow.Insert
            Selection.Offset(1, 0).Select
        End If
        Selection.Offset(1, 0).Select
    Loop While Selection.Value <> ""
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,099,933
Messages
5,471,612
Members
406,772
Latest member
imega

This Week's Hot Topics

Top