I want to highlight all the duplicates of a concatenated string in column I and provide an error message if there are any duplicates highlighted. However, there are several blan
If you want to use VBA this should work for you.
Dim mydict As Object
Dim iter As Long
Dim lastrow As Long
Dim errmsg As String
Dim key As Variant
Set mydict = CreateObject("Scripting.Dictionary")
' If you want to use early binding add in the Microsoft Scripting Runtime reference then: Set mydict = new dictionary
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
For iter = 2 To lastrow
If Not mydict.exists(.Cells(iter, "A").Value) Then
mydict.Add .Cells(iter, "A").Value, False
Else
.Cells(iter, "A").Interior.ColorIndex = 36
mydict(.Cells(iter, "A").Value) = True 'Keep track of which values are repeated
End If
Next
End With
errmsg = "Duplicate Values: "
For Each key In mydict
If mydict(key) = True Then 'Dupes
If Not errmsg = "Duplicate Values: " Then 'No extra comma
errmsg = errmsg & ", " & key
Else
errmsg = errmsg & " " & key
End If
End If
Next
MsgBox errmsg