VBA code for Text Diff between two columns?

Akila868

New Member
Joined
Aug 28, 2019
Messages
8
Hi friends,

I need big help on the following.

I have two columns with texts. Column A has the old text and Column B has the new text. I need to match these two and show in a 3rd column the additional characters (highlighted in red color) in B column compared to A column text. Further in D column to show the additional characters separately.

Would really appreciate if this can be done. Thanks in advance. :)
Ex.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Column A
[/TD]
[TD]Column B
[/TD]
[TD]Column C
[/TD]
[TD]Column D
[/TD]
[/TR]
[TR]
[TD]Test123$ New.
[/TD]
[TD]Test123E Newest
[/TD]
[TD]Test123E Newest
[/TD]
[TD]Eest
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Here's the result I got, it isn't what you expected? [TABLE="width: 426"]
<tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ABC$123.[/TD]
[TD]ABCU123.[/TD]
[TD]ABCU123.[/TD]
[TD]U[/TD]
[/TR]
[TR]
[TD]DDD;889@[/TD]
[TD]DDDL889P[/TD]
[TD]DDDL889P[/TD]
[TD]LP[/TD]
[/TR]
[TR]
[TD]Dustin[/TD]
[TD]Duxtinx[/TD]
[TD]Duxtinx[/TD]
[TD]xx[/TD]
[/TR]
</tbody>[/TABLE]

Yes. But this is what I am getting. I used in some other data I had.

[TABLE="width: 638"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]Column A[/TD]
[TD]Column B[/TD]
[TD]Column C[/TD]
[TD]Column D[/TD]
[/TR]
[TR]
[TD]Testing Medical Institute Ltd.[/TD]
[TD]Testing Medical Institute Limited[/TD]
[TD]Testing Medical Institute Limited
[/TD]
[TD]imited
[/TD]
[/TR]
[TR]
[TD]Lester Mango Exports LLc[/TD]
[TD]Lester Mang Exports, LLc[/TD]
[TD]Lester Mang Exports, LLc
[/TD]
[TD] Exports,
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Your new example, that's a different story, sorry I don't know how amend the code to deal with such case.:confused:
Hope someone else would step in.
 
Upvote 0
The reply given by Akuini is what you expected as per your previous post.
But I understand that you want something else.
Please give some explanations.

You have mentioned :
'Just need to compare character by character from left to right in the same order and display difference in characters.'

The original text is displayed in Column C.
The differences in characters are shown in color in Column C.
The additions are shown in Column D.
Do you want just to display in Column C the differences in characters shown in color omiting the original Text?

You have mentioned :
'It should instead highlight the characters that came in new/ removed/ replaced by comparing the two words in two columns.'

The characters that came in new are shown in red along with the original text in Column C.
What else do you want?

Do you want just to display the characters that are removed?
If so, in which column?
How, in Red or in Black?
With the Original text or without?

Do you want just to display the characters that are replaced?
If so, in which column?
How, in Red or in Black?

It will be good if you give an example of the original text in Column A, the modified text in Column B, along with what all you want to be displayed in what columns and in what colors.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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