+ Reply to Thread
Results 1 to 8 of 8

Macro to search for specific words in proximity to each other?

  1. #1
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Macro to search for specific words in proximity to each other?

    Hi,

    Basically, I have two columns of cells.

    Column A has a reference number, and Column B has a product.

    I'm trying to fashion a macro that will recognise when a reference in Column A has a specific pair of products. And copy the data over to the next column.

    The products in orders can exist seperately on different lines, but I'm looking to filter out order references that have both specific products on order.
    Here's an example using fruit:


    A B C D
    001 APPLE 001 APPLE & PEAR
    001 PEAR 004 APPLE & PEAR
    002 APPLE
    003 APPLE
    004 APPLE
    004 PEAR
    005 PEAR
    006 APPLE

    Is this at all possible?

    Any help you can send my way would be much appreciated.
    Last edited by BPSJACK; 07-25-2014 at 11:29 AM.

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

    Re: Macro to search for specific words in proximity to each other?

    Does this help?

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: Macro to search for specific words in proximity to each other?

    That's really great thanks, it does exactly what I wanted it to.

    However is there a way to expand on it?

    For example; I might have lots of different types of fruit in column A. Is there a way to instruct the macro to only identify certain pairings. So I would have lots of orders with different selections of fruit, but it would only filter orders that specifically have both an apple & pear?

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

    Re: Macro to search for specific words in proximity to each other?

    Try:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: Macro to search for specific words in proximity to each other?

    Hi, yes that seems to be working. Thank you very much

    However, is there a way to tweak the code to include another column (quantity) to copy over. eg:



    ref fruit qty ref fruit qty
    001 apple 1 001 apple & pear 1
    001 pear 1 004 apple & pear 2
    002 apple 1
    003 apple 1
    004 apple 2
    004 pear 2
    005 pear 1

  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: Macro to search for specific words in proximity to each other?

    Try:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    01-06-2012
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    165

    Re: Macro to search for specific words in proximity to each other?

    That's amazing thank you very much

  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: Macro to search for specific words in proximity to each other?

    You're welcome. Glad to help out and thanks for the feedback.

+ 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. Search for specific words
    By Newberry in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  2. Search for specific words
    By Dave R. in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-06-2005, 07:05 AM
  3. [SOLVED] Search for specific words
    By Dave R. in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 04:05 AM
  4. Search for specific words
    By Newberry in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  5. Search for specific words
    By Newberry in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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