+ Reply to Thread
Results 1 to 8 of 8

VBA Code or Formula to Match Text Descriptions by # of Word Similarities

  1. #1
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    VBA Code or Formula to Match Text Descriptions by # of Word Similarities

    I am stumped on a recent request I have been given in excel and was hoping someone might be able to help me out. Broadly, we are trying to come up with a way to take two different lists of product descriptions and come up with up with matches based on the number of words that match in each description.

    I made an example file (attached) of what the original two lists look like and what the intended outcome is supposed to look like. For this specific process, the team would like me to take the first 4 words of DESC LIST 1 and then pull in up to 5 descriptions from DESC LIST 2 where those 4 words can be found. For example, the first product would be split as follows (after comma removal):

    1. Pretzel
    2. Soft
    3. Baked
    4. Frozen

    You will then see that there are 8 examples on the second list that contain those four words, and the first 5 of those examples are brought into the columns on the second tab. The trick is that the first 4 words of the DESC LIST 1 can be found in any order or location within the DESC LIST 2 product description – this is where I am struggling to come up with a formula or macro that can do this. Formulaically speaking, a match for this item could be something like “Baked Soft Everything Pretzel Bun, Frozen” just because it contains those 4 words within the text.

    Thank you in advance for your time!
    Attached Files Attached Files

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

    Re: VBA Code or Formula to Match Text Descriptions by # of Word Similarities

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Re: VBA Code or Formula to Match Text Descriptions by # of Word Similarities

    This is perfect, thank you! I do have two edits, if possible.

    1. Could you move the results over one column so that the original DESC List 2 stays in place?
    2. Is it possible to update the code so that if there are less than 4 words in the Desc List 1 (for example, "Pretzel, Soft Baked"), results would still pull for it using all of the words available?

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

    Re: VBA Code or Formula to Match Text Descriptions by # of Word Similarities

    Quote Originally Posted by NicoleAL123 View Post
    This is perfect, thank you! I do have two edits, if possible.

    1. Could you move the results over one column so that the original DESC List 2 stays in place?
    2. Is it possible to update the code so that if there are less than 4 words in the Desc List 1 (for example, "Pretzel, Soft Baked"), results would still pull for it using all of the words available?
    I can do that. One question though. Do you want whole word matches only e.g.; Baked doesn't match Parbaked? Or partial word matches are okay?

  5. #5
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Re: VBA Code or Formula to Match Text Descriptions by # of Word Similarities

    If you could do specific word matches instead of partial word matches, that would be even better! thank you!

  6. #6
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Re: VBA Code or Formula to Match Text Descriptions by # of Word Similarities

    Hi,

    If it is not easy to do the partial word match, it would still be very helpful to have a code that continued to work if some text strings are contain 3 or less words. Either way, let me know if this is possible! Thanks!

  7. #7
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Re: VBA Code or Formula to Match Text Descriptions by # of Word Similarities

    NicoleAL123

  8. #8
    Registered User
    Join Date
    10-02-2017
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    22

    Re: VBA Code or Formula to Match Text Descriptions by # of Word Similarities

    Quote Originally Posted by NicoleAL123 View Post
    NicoleAL123
    NicoleAL123.
    Last edited by NicoleAL123; 05-02-2018 at 10:07 AM. Reason: Delete

+ 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. Match Styles in Cross-Reference (from Bookmark) to match surrounding text in Word (VBA)
    By JimmyWilliams in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2017, 07:39 AM
  2. Match Styles in Cross-Reference (from Bookmark) to match surrounding text in Word (VBA)
    By JimmyWilliams in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2017, 10:52 PM
  3. Replies: 6
    Last Post: 02-03-2015, 04:45 PM
  4. Replies: 6
    Last Post: 08-21-2014, 01:04 PM
  5. Match Item descriptions with Col A, B and C
    By Vinnie Chan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2012, 05:31 PM
  6. macro to read descriptions, match in different worksheets and display values
    By aysrun in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-22-2009, 04:13 AM

Tags for this Thread

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