• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

compare multiple text in 2 columns

koi

Member
Hi All,

hope you are all good and well, I have this most difficult task that i cannot solve, hope that you have the answer for it.

example 1:
in column A i have : I.like.eat.sushi
in column B i have : like.meat
in column C i would want it to say : I.eat.sushi

example 2:
in column A i have : I.like.eat.sushi
in column B i have : I.like.meat.eat
in column C i would want it to say : sushi

in simple things, it will search every word in column B and compare to column A, and write the non exist words in column C

can it be done something like that? and I dont mind of VBA solution if formula not possible or took a very long formula to make it

Thanks All, Appreciate for the suggestion.
 
Try this UDF
Code:
Function ExcludeWords(strStart As String, strExclude As String, myDelim As String) As String
    Dim firstA() As String
    Dim strTest As String
    Dim i As Long, j As Long
    Dim strFind As String
   
    firstA = Split(strStart, myDelim)
    strTest = myDelim & strExclude & myDelim
   
    For i = LBound(firstA) To UBound(firstA)
        strFind = myDelim & firstA(i) & myDelim
        If InStr(1, strTest, strFind) = 0 Then
            ExcludeWords = ExcludeWords & firstA(i) & myDelim
        End If
    Next i
   
    If ExcludeWords <> "" Then
       ExcludeWords = Left(ExcludeWords, Len(ExcludeWords) - Len(myDelim))
    End If
   
End Function

Formula then would be:
=ExcludeWords(A2,B2,".")
 
Hi Luke,

Amazing Job, you got it first time right, thanks a lot for helping me !

koi
 
Hi Luke,

if now i want to find the similiar things between A & B, with the sample above, can it also be done? Thanks
 
Back
Top