Comparison string or words between two columns

lalro143

New Member
Joined
May 30, 2014
Messages
39
Hi,

I have two columns in which we have different words.

Now I need to compare Col A with Col B and find out the unmatched word of Col B in Col C.

In below case "Hi" is the word which is not in Col A.

For Example

Col A Col B Col C (Output Unmatched Words)
Hello Vijay Kumar Kumar Hello Vijay Hi Hi

Thanks in advance
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi,

I have two columns in which we have different words.

Now I need to compare Col A with Col B and find out the unmatched word of Col B in Col C.

In below case "Hi" is the word which is not in Col A.

For Example

Col A Col B Col C (Output Unmatched Words)
Hello Vijay Kumar Kumar Hello Vijay Hi Hi

Thanks in advance

lalro143,

Are you looking for a formula solution, or, a macro?

By your description, I am not able to determine where your actual raw data is, and, what the results should look like.


See reply #2 at the next link, if you want to show small screenshots, of the raw data, and, what the results should look like.

http://www.mrexcel.com/forum/about-board/508133-attachments.html#post2507729


Or, you can post your workbook/worksheets to the following free site (sensitive data changed), mark the workbook for sharing, and, provide us with a link to your workbook:

https://dropbox.com
 
Upvote 0
Cell A2- Hello Vijay Kumar

Cell B2- Kumar Hello Vijay Hi

Cell C2- Hi

Above you can see cell A2 has some words which needs to be compared with cell B2 words. Above you can see only "Hi" is the word which is not in Cell A2 but it is in Cell B2. So my final output is in cell C2=Hi.

This is only sample. Have to do the same activity with 50000 cells. A Macro would be great help.[TABLE="width: 310"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD]

[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 310"]
<colgroup><col><col><col></colgroup><tbody></tbody>[/TABLE]
 
Upvote 0
See if this macro does what you want. If not, please explain & give examples that demonstrate the issues. One example wasn't a lot to go on. ;)

Test in a copy of your workbook.

Code:
Sub UnmatchedWords()
  Dim d As Object
  Dim a As Variant, b As Variant, aWords As Variant, wrd As Variant
  Dim i As Long
  
  Set d = CreateObject("Scripting.Dictionary")
  d.CompareMode = 1
  a = Range("A2", Range("B" & Rows.Count).End(xlUp)).Value
  ReDim b(1 To UBound(a), 1 To 1)
  For i = 1 To UBound(a)
    d.RemoveAll
    For Each wrd In Split(a(i, 2))
      d(wrd) = 1
    Next wrd
    For Each wrd In Split(a(i, 1))
      If d.exists(wrd) Then d.Remove wrd
    Next wrd
    b(i, 1) = Join(d.keys)
  Next i
  Range("C2").Resize(UBound(b)).Value = b
End Sub

Results with my small dummy data:

Excel Workbook
ABC
1Data 1Data 2
2Hello Vijay KumarKumar Hello Vijay HiHi
3Good dayDay Good
4hello worldgreen redgreen red
5red black whiteblack blue red greenblue green
Unmatched words
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top