Results 1 to 4 of 4

VBA; Search for string/row. Cut/Insert rows.

Threaded View

  1. #1
    Registered User
    Join Date
    06-01-2010
    Location
    Pacific, Ocean
    MS-Off Ver
    Excel 2002
    Posts
    6

    VBA; Search for string/row. Cut/Insert rows.

    Relatively new to macros and I'm starting to venture past the recorder. I've been knocking my head against the wall on this...

    I would like to search a short range in one column (B1:B50) for two of 5 names.

    Two, and only two of the five names will always appear in the range. And, each name will only appear once. However, the location of the two names within the range will vary from one day to the next.

    When the first name is found, I would like to cut the row containing the name and the two rows immediately below it and insert them at row 15 (B15:B17).

    Resuming the search at B18, when the second name is found, I would like to cut the row+2 and insert them at row 25 (B25:B27).

    Example. Names: John, Joe, Jack, Jill, Jane. 'Jill' is located in cell B27. 'John' is located in cell B33.

    What VBA code would, 1) search for the names in range B1:B50, 2) identify the row when a name is found 3) activate (for the 'Jill/John' example) row 27:29 and 4) insert them at row 15 (new position, row 15:17). And, then repeat the cycle for 'John'?

    Any help would be greatly appreciated.
    Last edited by tw9901; 06-03-2010 at 11:10 PM.

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