+ Reply to Thread
Results 1 to 20 of 20

Compare 2 columns and display result in 3 column also with part words

  1. #1
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Compare 2 columns and display result in 3 column also with part words

    Hi I have been fighting with this long time. I have in the real sheet1 column A around 1026 names and in column B around 546 names.
    I need to compare partly and display the result in column E.
    More than one thing give me problems. In cell A1 and cell B1 i have the word N KOCHS SKOLE For some reason it dont find a match there. I have tried find different clean macros but the same problem. I am afraid that in the real sheet it will be more than this one and cant find out why.
    Try have a look at my test sheet.
    I need the macro to find partly. As you can see it in the test sheet cant find the match just there is dot or example a -
    So that is a problem . Its basically type control F and example write KOCH . Here it will find 3 examples . I have changed all to uppercase. But it should also not be necessary if i have the right macro i think. So in the real sheet i cant count with this.
    My macro color the matches yellow in column B. But i think it it could find it partly, it would be better to write the matches in column E seperately.
    So then after you can fast check if its really a correct match.
    Try have a look at my test sheet. I have written some in column E. Wanted result and also what is the problem.

    Please have a look my test sheet would really be nice to solve. And i need it partly matches, like when you make a control F and search

    P.s here is the code i use for colour but i think its not good and would like change so it can display the result in column E

    Please Login or Register  to view this content.
    Sincerely Abjac
    Attached Files Attached Files
    Last edited by abjac; 04-28-2019 at 12:41 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Compare 2 columns and display result in 3 column also with part words

    column A is showing no space after SKOLE while column B has a space after. All of the other names I checked had a space after the last character of the name. It is odd that using xlPart would not still find the match. I have no idea how this can occur.
    Last edited by JLGWhiz; 04-28-2019 at 03:06 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    Yes i guess its not the space or it should not be. Its very weird. So its not solved sure. But thanks for the reply

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Compare 2 columns and display result in 3 column also with part words

    Quote Originally Posted by abjac View Post
    Yes i guess its not the space or it should not be. Its very weird. So its not solved sure. But thanks for the reply
    If your data is downloaded from the internet, what appears to be space could be a non printing character other than a space, but even then the xlPart should pick up the name Unless there is a different character between the text in the cells, then it would not detect the xlPart. I did not check for that, and am not sure how to go about checking it. But if you retype both values in their respective cells and run the code and it finds the match, then it would pretty much confirm that there was a hidden character between the text strings. Logically, there has to be a difference somewhere between the beginning and ending of that string of text for it not to find a match in the other range.

    I just did an ASCII check on each character in both strings, using the worksheet in the link. There is no non-printing characters in the strings and they match character for character except for the extra space in column B. So that shoots my hidden character theory in the foot. I am at a complete loss on this one. Here is the code I ran to check the ASCII values. your worksheet was the active sheet at runtime.

    Please Login or Register  to view this content.
    Last edited by JLGWhiz; 04-28-2019 at 08:18 PM.

  5. #5
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    HI JLGWhiz .
    And thanks for the answer, early morning here soon go work. Yes its very very weird. Before i posted it, i ran several codes cleaning macros from internet, And no matter what i did and try, it did not give the right result. My question is if my code is correct ? But i think it is. The problem for me of course is that in the real sheet, where i have to find the matches. I know it will not be correct.
    So its a quite big problem.
    Thanks for trying. I hope some more will take this challenge, and try figure out, what its wrong. Because this is really weird
    So all who want to try , use the test sheet and try figure it out. I have tried so much with this one.
    So dont hold your self back. Hope some can figure it out.
    Sincerely Abjac

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Compare 2 columns and display result in 3 column also with part words

    Try
    Please Login or Register  to view this content.

  7. #7
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Compare 2 columns and display result in 3 column also with part words

    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.
    This finds it OK, but I would still like to know why the other code didn't find it.

  8. #8
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    Hi. JIndon. First home from work now. Sorry the late reply but big time difference. And thanks so much for your answer.
    I tried the code but i get an error in this line

    .FormatConditions.Add xlExpression, , "=countif(a1,b1&""*"")>0"

    I use excel 2010 dont know if that mean some.

    Sincerely Abjac

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Compare 2 columns and display result in 3 column also with part words

    Quote Originally Posted by JLGWhiz View Post
    column A is showing no space after SKOLE while column B has a space after. All of the other names I checked had a space after the last character of the name. It is odd that using xlPart would not still find the match. I have no idea how this can occur.
    As the col B value has an extra space it won't be found ("SKOLE " is not part of "SKOLE"), however if the find was switched so that you looked for the col A value in col B, then it would be found ("SKOLE" is part of "SKOLE ")

  10. #10
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Compare 2 columns and display result in 3 column also with part words

    Quote Originally Posted by Fluff13 View Post
    As the col B value has an extra space it won't be found ("SKOLE " is not part of "SKOLE"), however if the find was switched so that you looked for the col A value in col B, then it would be found ("SKOLE" is part of "SKOLE ")
    My longevity is showing. I looked at that and concluded that same thing, but failed to realize the code was looking in reverse. Second set of eyes always helps.

  11. #11
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    Hi and thanks for the answers. That means the space after the word in skole? I though it would not matters. Same to remove dots and example -. Then it will find it yes. But i thought it was not that important. I cant make jindons code work it give me an error.
    What are your proposal if i have to run this code in the real sheet with more names? How can i be sure it will be correct ?
    I can remove dot and - yes but how to remove the space after the last word skole ? I am just surprised this means much. That it cant find it because of this. Sincerely abjac

  12. #12
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Compare 2 columns and display result in 3 column also with part words

    Simple change to original code.

    Please Login or Register  to view this content.
    Last edited by JLGWhiz; 04-29-2019 at 02:40 PM.

  13. #13
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    Hi. JLGWhiz

    That works great but what about the characters dot and - and others maybe. Cant the code not find it with them or it need to be changed. But this solve the trim problem and spaces sure. Thanks . The other would like to have also to be sure in the original sheet the result will be correct.
    By the way would it not be necessary also to trim in column A to be sure ?


    Sincerely
    Abjac
    Last edited by abjac; 04-29-2019 at 03:34 PM.

  14. #14
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    Hi. JLGWhiz
    Just saw your last update. Not totally what i want. What i need to display in column E is the matches. Its because i need see if they are related to be sure. And the macro find part matches.
    Example
    N KOCH SKOLE Match
    N KOCH SKOLE Match
    KOCH SKOLE Match
    KOCH KITCHENS " it will display KOCH KITCHENS because of the word KOCH but this is another company. So that i can fast see. So i need the matches to be displayed in column E and not the non matches-
    But also now it dont find the matches with symbols as . , - and others. The 3 white now are matches but it dont find because of the dot.

    Hope i explain it ok.
    Sincerely
    Abjac
    Last edited by abjac; 04-29-2019 at 03:47 PM.

  15. #15
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Compare 2 columns and display result in 3 column also with part words

    This will put the matches in column E. As for the ones with (-), (,), (.) or other symbols which prevent matches, they are not matches and I don't know how to tell which ones need to have the symbols and which ones don't. You could run a 'Replace' macro to remove symbols, but in doing so, you might create matches thar are not true matches. I think it is better to manually review the exceptions cause by the symbols and make manual corrections to the data base, rather than try to do it by code.

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    HI JLGWhiz .

    Yes maybe you are right about that. I think this will work fine. Thanks so much for all your help. Its really nice and good help thanks a lot.

    Sincerely Abjac.

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Compare 2 columns and display result in 3 column also with part words

    Quote Originally Posted by abjac View Post

    .FormatConditions.Add xlExpression, , "=countif(a1,b1&""*"")>0"

    I use excel 2010 dont know if that mean some.
    Should work, see attached.
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    Hi Jindon and thanks
    I tried in your sheet and it still give me a run time error in this line

    .FormatConditions.Add xlExpression, , "=countif(a1,b1&""*"")>0"

    Sincerely Abjac

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Compare 2 columns and display result in 3 column also with part words

    Don't know why
    Try change that line to
    Please Login or Register  to view this content.
    Or this colors the cell(s)
    Please Login or Register  to view this content.

  20. #20
    Forum Contributor
    Join Date
    07-28-2012
    Location
    madrid
    MS-Off Ver
    Excel 2010 at work excel 2016
    Posts
    1,102

    Re: Compare 2 columns and display result in 3 column also with part words

    Hi Jindon and thanks
    The first code still give the same error. But the second color it so weird. But thanks a lot for the work . Dont know why the first give this error

    Sincerely Abjac

+ 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] Compare two columns - words by word - display number of word match
    By nasrulla in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-24-2018, 06:18 AM
  2. [SOLVED] Compare words in 2 columns, formula for unique words in 3rd column
    By thecdnmole in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-08-2018, 01:58 PM
  3. Compare words in 2 columns, formula for unique words in 3rd column
    By thecdnmole in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-07-2018, 06:26 PM
  4. [SOLVED] How to compare data from two columns if match get the result from third column
    By devawad in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-06-2017, 12:43 AM
  5. [SOLVED] compare 2 columns provide result in 3rd column
    By snakesbee in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-29-2015, 11:34 AM
  6. [SOLVED] compare A and C column if match my logic display result in B column
    By vengatvj in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 11-03-2013, 02:07 AM
  7. compare 2 columns and result in 3th column
    By danusko in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-08-2009, 06:53 AM

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