I have a column of data in which i have string values. I want to do a comparison by each cell in that column and check whether the value is a duplicate or not. The comparison needs to be both full text as well as wild cards.
below is the screenshot of my data
if you see the screenshot, the company CES Limited exist in the row 3 as well as on row 17 along with another company ECLERX SERVICES LTD | CES Limited. So I want to highlight the duplicate values like this.
Below is the code I wrote
Dim rangeToUse As Range, singleArea As Range, cell1 As Range, cell2 As Range, i As Integer, j As Integer
Set rangeToUse = Selection
Cells.Interior.ColorIndex = 0
Cells.Borders.LineStyle = xlNone
For Each singleArea In rangeToUse.Areas
singleArea.BorderAround ColorIndex:=1, Weight:=xlThin
Next singleArea
For i = 1 To rangeToUse.Areas.Count
For Each cell1 In rangeToUse.Areas(i)
MsgBox cell1.Value
For j = 1 To rangeToUse.Areas.Count
For Each cell2 In rangeToUse.Areas(j)
If cell1.Value = cell2.Value Then
cell2.Interior.ColorIndex = 38
End If
MsgBox cell2.Value
Next cell2
Next j
Next cell1
Next i
however the code highlights all the cells as different. Can anyone let me know where I am doing wrong?