Highlight just the Similar Text between 2 Cells - New Thread

CF64

New Member
Joined
Feb 17, 2021
Messages
48
Office Version
  1. 365
Platform
  1. Windows
Hello, I am utilizing the following solution code which was posted in a related closed thread:

Sub rhelm()
Dim Cl As Range, Rng1 As Range, Rng2 As Range
Dim Sp As Variant
Dim i As Long, Pos As Long

With Selection
If .Areas.Count > 1 Then
Set Rng1 = .Areas(1)
Set Rng2 = .Areas(2)
Else
Set Rng1 = .Columns(1)
Set Rng2 = .Columns(2)
End If
End With
For Each Cl In Range(Rng1(1), Rng1.Range("A" & Rows.Count).End(xlUp))
Sp = Split(Cl.Value)
For i = 0 To UBound(Sp)
Pos = InStr(1, Rng2.Range("A" & Cl.Row).Value, Sp(i), vbTextCompare)
If Pos > 0 Then Rng2.Range("A" & Cl.Row).Characters(Pos, Len(Sp(i))).Font.Color = vbRed
Next i
Next Cl
End Sub

The code is working on some cells (highlighting just the similar text from adjacent column), but on some cells it is highlighting all words and wondering if it could be due to formatting issues in column 1 or any other suggestions. Thank you.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I found the solution. All cells which had a double space highlighted all words, once replaced double spaces with single spaces, it worked.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,454
Messages
6,124,931
Members
449,195
Latest member
Stevenciu

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