+ Reply to Thread
Results 1 to 7 of 7

Find 2 words and copy and paste everything in between

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Question Find 2 words and copy and paste everything in between

    I want a macro to search column A for the word Starting Time. I then want it to look in Col A for the word Ending Time. I then want to copy every cell in Col A between those words and paste it into sheet2 A1. After this, I want it to repeat the above except look for the 2nd time that Starting Time appears and the 2nd time that Ending Time appears and copy everything in between and paste into sheet2 B1. Thanks in advance!

    The word Ending Time will always occur after Starting Time
    Last edited by ScabbyDog; 03-17-2013 at 03:50 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Find 2 words and copy and paste everything in between

    Please Login or Register  to view this content.
    The above I think is almost there. I just need to alter the line in red so that it only copies column A and not all the columns between where the words were found.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find 2 words and copy and paste everything in between

    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Find 2 words and copy and paste everything in between

    Says object variable or with block not set and highlights the Loop Until strFirstStart etc line. It pastes the data exactly how I want other than that. How do I solve the error message? Thanks for your help!

    EDIT: Forget what I said above Alpha. Works a charm!!!!!
    Last edited by ScabbyDog; 03-17-2013 at 05:43 PM.

  5. #5
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Find 2 words and copy and paste everything in between

    How do I change it to paste in col F the first time, and then when it loops and finds the 2nd instance of words paste it into G.
    Last edited by ScabbyDog; 03-17-2013 at 05:52 PM.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Find 2 words and copy and paste everything in between

    Add this one line...

    Please Login or Register  to view this content.

  7. #7
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Re: Find 2 words and copy and paste everything in between

    Thanks Alpha. Brilliant as always. How would I alter it if I wanted to reverse the words. So look for Ending Time first. How would I alter it so that when it loops, it would search for the 2nd(or last instance as there will only ever be 2instances of the word)

+ 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