+ Reply to Thread
Results 1 to 9 of 9

vba to align 2 columns that have similar (not exact) wording

  1. #1
    Registered User
    Join Date
    04-27-2014
    Location
    Argentina
    MS-Off Ver
    Excel 2010
    Posts
    12

    vba to align 2 columns that have similar (not exact) wording

    Hi all,

    Wish you all a merry Christmas and happy new year.

    This time i am seeking your support to find a vba that align cells from 2 excel columns that have similar text, but not exact one. Some background: This happens because 2 different clients call a same document with different name: eg. list of home appliances 1.0 12dec2014 vs home appliances list 12-Dec-14, feedback from client 1jan2019 vs client feedback 1-1-2019. Sometimes the name can be much longer. So column A is how client A named the documents and column B is how client B named the documents. I need the vba to align cell from column A with the most similar cell from column B in order to check if version and date is the same. Sometimes i can have 20 documents, i.e. 20 rows., and in order to check that the documents were assigned the same version i would start with row 1 column A, scroll down column B to find the row which has the name assigned to that file by client B and check the version and date. Then i have to go to cell A2, scroll thru column B to find out which cell has the name of the document and then check if the version/date matches. I imagine this Vba picking up each word from cell A1 (avoid numbers and dates in this analysis as this will be dona manually once the cells are aligned), checking the presence of that word in all of the cell from column B, assigning a score to each cell of column B depending on if the word was found and the length of the word (if there is a match, the longer the word is, the larger should be the score assigned), then the cell from column B that gets the larger score should be sorted to be in the same row as the cell from column A being analyzed. Hope this makes sense.

    All the best!

    Pablo

  2. #2
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: vba to align 2 columns that have similar (not exact) wording

    Hi,

    Give us an example workbook
    with both the cases

    1 sheet with the data unsorted
    1 sheet with the data sorted

    thx
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  3. #3
    Registered User
    Join Date
    04-27-2014
    Location
    Argentina
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: vba to align 2 columns that have similar (not exact) wording

    Quote Originally Posted by Joske920 View Post
    Hi,

    Give us an example workbook
    with both the cases

    1 sheet with the data unsorted
    1 sheet with the data sorted

    thx
    Hi Joske920,

    Thank you for you time. Please find attached the requested spreadsheet.

    Regards,

  4. #4
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: vba to align 2 columns that have similar (not exact) wording

    Hi,

    After thinking not to do it.. I took it as a challenge because its not evident to make this in a few minutes

    Please Login or Register  to view this content.
    It may not be pretty but it does the job
    (Not tested extensively)

    I hope you can use this.. this was not easy to me..
    Last edited by Joske920; 12-21-2019 at 11:27 AM. Reason: removed some code that was meant to be for bigger data sets but wasn't optimized overall

  5. #5
    Registered User
    Join Date
    04-27-2014
    Location
    Argentina
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: vba to align 2 columns that have similar (not exact) wording

    Thank you Joske920 !

    I appreciate your time and expertise! I'll test it for a couple of days and let you know.

    Thank you again!

    Quote Originally Posted by Joske920 View Post
    Hi,

    After thinking not to do it.. I took it as a challenge because its not evident to make this in a few minutes

    Please Login or Register  to view this content.
    It may not be pretty but it does the job
    (Not tested extensively)

    I hope you can use this.. this was not easy to me..

  6. #6
    Registered User
    Join Date
    04-27-2014
    Location
    Argentina
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: vba to align 2 columns that have similar (not exact) wording

    Hi Joske920 !
    It works wonderfully with the example I sent you. Great work. The problem is I've checked it with another scenario and had some issues. I've tried to replicate it by modifying a little bit the spreadsheet i sent to you. For example, if i copy 1 item from List A and paste it at the end of List B, I would think that the macro will necessary align them (as they are equal), but for some reason the macro didn't align those cells. Question: is the macro picking 1 item from List A, searching for best fit from list B and then reversely checking if that item form list A is the best fit for the selected item from list B? For example: macro finds best fit for cell A3 is B14. Does the macro check that best fit of item B14 is A3?
    Thanks again!

  7. #7
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: vba to align 2 columns that have similar (not exact) wording

    Hi,

    No it does not check right to left only left to right
    so:

    the first from list A gets compared to list B and it splits the sentence up and checks for these words and calculates the percentage of letters that are equal
    also it deletes all characters like /-()[]{} and so on to a space to remove the clutter sort of speak and split up the sentence in more words

    im sure this isn't fail proof. and there is probably a better way doing this.

    Grtz

  8. #8
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: vba to align 2 columns that have similar (not exact) wording

    Hi,

    You could try this way
    It compares for each word without removing the not the most equal

    replace the ReturnMostLikely function with this one or give the old one a different name like ReturnMostLikelyOLD and past this under all the other code

    Please Login or Register  to view this content.
    Grtz
    Last edited by Joske920; 12-22-2019 at 04:26 PM. Reason: little typo

  9. #9
    Registered User
    Join Date
    04-27-2014
    Location
    Argentina
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: vba to align 2 columns that have similar (not exact) wording

    Thanks Joske920! I will check it and let you know. Again i really appreciate your time and work.

+ 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 to exact and similar
    By SPIG in forum Excel General
    Replies: 5
    Last Post: 07-15-2019, 06:55 PM
  2. Compare two columns for Exact match and Similar matches
    By murtz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2014, 08:16 AM
  3. Replies: 2
    Last Post: 09-15-2014, 09:58 AM
  4. Replies: 0
    Last Post: 07-24-2013, 11:13 AM
  5. Formula to align two columns with nearly similar text and attached numeric columns
    By Benefits Recon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2012, 12:03 AM
  6. [SOLVED] Similar vs. Exact comparison
    By dave in Toronto in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-31-2005, 06:05 PM
  7. MATCH function - 2 columns w/ SIMILAR, not EXACT data
    By Jane in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-05-2005, 12:06 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