+ Reply to Thread
Results 1 to 3 of 3

Insert rows beneath cells containing specific text

  1. #1
    Registered User
    Join Date
    12-02-2008
    Location
    London
    Posts
    51

    Insert rows beneath cells containing specific text

    Hi,

    I am trying to format a large number of tables for pasting into a Word doc.

    Is there an easy way to insert a row on a worksheet beneath any cell containing specific text - in this case, 'market summary'.

    Many thanks,

    Adam
    Last edited by adame; 07-22-2011 at 07:03 AM.

  2. #2
    Registered User
    Join Date
    12-02-2008
    Location
    London
    Posts
    51

    Re: Insert rows beneath cells containing specific text

    I figured it out if anyone is interested!

    Sub Insert_Rows()
    Rw = 2
    LastRow = 525
    NxtChk:
    If Cells(Rw, "f") = "Market summary" Then
    Rows(Rw + 1).EntireRow.Insert
    Rw = Rw + 1
    NewRow = NewRow + 1
    End If
    If Rw = LastRow + NewRow Then Exit Sub
    Rw = Rw + 1
    GoTo NxtChk
    End Sub

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Insert rows beneath cells containing specific text

    number your rows down from 1 to end
    say your test is in column a2:a1001 so 1 to 1000 in say col x x2:x1001
    after thest entry in x in this case x1002 put =if(a2="market summary",x2,"") drag down to row 2002
    now sort by column x
    if cell contains more text than just markrt summart
    use
    =if(isnumber(SEARCH("market summary",A2)),x2,"")
    see small example using col b
    just sort by sort colum b then delete col b
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1