VBA / Compare two columns and show differences in a third column

ariel_733

New Member
Joined
Feb 8, 2022
Messages
1
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
Platform
  1. Windows
  2. MacOS
Hello ?

I would like to compare 2 columns populated with a lot of text in each cell, and then have inserted on the right a third column that would mark the differences between the two selected columns.
For example, I have some outdated text in column A, and some newer, amended text in column B. What I want is a new column to be inserted on the right, populated with the same text in B, but with all the differences from column A marked as follows:
1. deleted text in red and strikethrough
2. new words added, not present in A, in blue.

Thank you in advance!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You can do it without code, like this

I tested with data in B3:B14 and C3:C11 - change these to your ranges

This formula will append the two ranges one above the other and then remove duplicates. In other words, it will give you a unique list of the items in both columns.
Excel Formula:
=UNIQUE(LET(s,SEQUENCE(COUNTA(B3:C14)),IF(s<=COUNTA(B3:B14),B3:B14,C3:C11)))
I put this formula in F3

You can use conditional formatting to colour this combined list. It needs two formulae, one for each colour
For the items which have been removed (were in list 1, are missing in list 2), I used this formula with conditional formatting for F3, the first cell of the combined list
Excel Formula:
=(IFERROR(MATCH($F3,$C$3:$C$11,0),0)=0)
and set formatting to red, strikethrough, and I copied this formatting down the column
For the items which have been added (are in list 2 but not in list 1), I used this conditional formatting formula for F3 (and set the colour blue and copied formatting down)
Excel Formula:
=(IFERROR(MATCH($F3,$B$3:$B$14,0),0)=0)
 
Upvote 0

Forum statistics

Threads
1,224,871
Messages
6,181,497
Members
453,047
Latest member
charlie_odd

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