Hi All,
I have a macro to compare words between cells from column B and D. Currently it is highlighting the matching words in column D. instead I want to highlight the column B. pasted the code below. Can someone pls help me on this?
Sub CompareWords()
Dim xStr() As String
Dim i As Long
Dim x As Long, y As Long
With ActiveSheet
For i = 2 To .Cells(.Rows.Count, "B").End(xlUp).Row
xStr = Split(.Cells(i, "B").Value, " ")
With .Cells(i, "D")
.Font.ColorIndex = 1
For x = LBound(xStr()) To UBound(xStr())
For y = 1 To Len(.Text)
If Mid(.Text, y, Len(xStr(x))) = xStr(x) Then
.Characters(y, Len(xStr(x))).Font.ColorIndex = 4
End If
Next y
Next x
End With
Next i
End With
MsgBox "completed"
End Sub
I have a macro to compare words between cells from column B and D. Currently it is highlighting the matching words in column D. instead I want to highlight the column B. pasted the code below. Can someone pls help me on this?
Sub CompareWords()
Dim xStr() As String
Dim i As Long
Dim x As Long, y As Long
With ActiveSheet
For i = 2 To .Cells(.Rows.Count, "B").End(xlUp).Row
xStr = Split(.Cells(i, "B").Value, " ")
With .Cells(i, "D")
.Font.ColorIndex = 1
For x = LBound(xStr()) To UBound(xStr())
For y = 1 To Len(.Text)
If Mid(.Text, y, Len(xStr(x))) = xStr(x) Then
.Characters(y, Len(xStr(x))).Font.ColorIndex = 4
End If
Next y
Next x
End With
Next i
End With
MsgBox "completed"
End Sub