I want to check for dupes in Row One
The Code below works fine for column ranges like:
myrng = Range(\"C2:C\" & Range(\"C65536\").End(x
Use Collections to get the unique values, then loop through the collections to highlight the duplicates.
Sub UsingCollection()
Dim cUnique As Collection
Dim Rng As Range
Dim Cell As Range
Dim sh As Worksheet
Dim vNum As Variant
Dim LstCol As Long
Dim c As Long, clr As Long, x, r As Range
Set sh = ThisWorkbook.Sheets("Nodes")
With sh
LstCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
Set Rng = .Range(.Cells(1, 1), .Cells(1, LstCol))
Set cUnique = New Collection
Rng.Interior.ColorIndex = xlNone
clr = 3
On Error Resume Next
For Each Cell In Rng.Cells
cUnique.Add Cell.Value, CStr(Cell.Value)
Next Cell
On Error GoTo 0
For Each vNum In cUnique
For c = 1 To LstCol
Set r = .Cells(1, c)
x = Application.WorksheetFunction.CountIf(.Range(.Cells(1, 1), .Cells(1, c)), r)
If r = vNum Then
If x > 1 Then
r.Interior.ColorIndex = clr
End If
End If
Next c
clr = clr + 1
Next vNum
End With
End Sub