Results 1 to 4 of 4

Thread: Insert Blank row before a specific term
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Mar 2010
    Posts
    179
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Insert Blank row before a specific term

    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

  2. #2
    Board Regular mumps's Avatar
    Join Date
    Apr 2012
    Location
    Toronto, Canada
    Posts
    7,868
    Post Thanks / Like
    Mentioned
    83 Post(s)
    Tagged
    5 Thread(s)

    Default Re: Insert Blank row before a specific term

    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
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Board Regular
    Join Date
    Mar 2010
    Posts
    179
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Insert Blank row before a specific term

    Hi Mumps - Thank you for the code (Y)

  4. #4
    Board Regular mumps's Avatar
    Join Date
    Apr 2012
    Location
    Toronto, Canada
    Posts
    7,868
    Post Thanks / Like
    Mentioned
    83 Post(s)
    Tagged
    5 Thread(s)

    Default Re: Insert Blank row before a specific term

    You are very welcome.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •