+ Reply to Thread
Results 1 to 11 of 11

Find word and if number appears below word then copy

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

    Find word and if number appears below word then copy

    I want a macro to search in column A only for the exact word that appears in cell D1. If it finds this word AND if a whole number appears in the cell directly below it then I want to copy one cell to the right and 15 cells down and paste it (transpose it) into sheet2 cell Z1.

    Example would be if it finds the word in cell A14 but there is no number in cell A15 then it keeps going and it finds the word again in cell A25 and a whole number is found in cell A26 then copy cells B26:B40 and paste it into sheet2 Z1 (transposed).

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Find word and if number appears below word then copy

    Might need to change the sheet names in the code on the first two lines, you never really specified what the first sheet is named.

    Please Login or Register  to view this content.
    Last edited by walruseggman; 01-11-2016 at 10:52 AM.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find word and if number appears below word then copy

    Another:

    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 word and if number appears below word then copy

    @Walruss That works BUT it doesn't take into account that there has to be a number found directly below the cell where D1 is found in column A before doing the copying and pasting. Once that has been added then it's perfect. Any idea how to add that clause?

    @John - That works but if the first time it finds the word and it has no number below it then it stops. It needs to keep searching until it finds a number under the word, then stop looping.
    Last edited by ScabbyDog; 01-11-2016 at 11:05 AM.

  5. #5
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Find word and if number appears below word then copy

    Try the code I posted above

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find word and if number appears below word then copy

    Not sure which post you are referring to:

    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Find word and if number appears below word then copy

    That works BUT it doesn't take into account that there has to be a number found directly below the cell where D1 is found in column A before doing the copying and pasting.
    It does evaluate that at this line, which works on my test sheet:

    Please Login or Register  to view this content.
    If it's not working for you, can you post a sample data set where the evaluation fails?

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Find word and if number appears below word then copy

    Maybe:

    Please Login or Register  to view this content.

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

    Re: Find word and if number appears below word then copy

    Brilliant guys, working perfectly based off your most recent code.

    How could it be altered if I wanted to find the 2nd instance of the word in column A which also appears with a number directly below it?

  10. #10
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Find word and if number appears below word then copy

    Please Login or Register  to view this content.

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

    Re: Find word and if number appears below word then copy

    Sorted! Thanks all.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] count number of times a word appears
    By m_789 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-19-2013, 10:16 AM
  2. Counting number of times a word appears across worksheets
    By danltd in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-24-2012, 04:33 AM
  3. Replies: 19
    Last Post: 05-26-2011, 04:15 PM
  4. Replies: 3
    Last Post: 10-02-2007, 09:53 AM
  5. count the number of times a specific word appears in a column
    By BAR in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-27-2006, 12:10 PM
  6. Counting the number of times a word appears 'anywhere' on a page
    By Brother Laz in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-17-2006, 10:10 AM
  7. [SOLVED] [SOLVED] Counting the number of times a word appears in a worksheet
    By Jig Bhakta in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-02-2005, 11:06 PM

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