Hi,
This is my approach, using macro.
Sub FilterIt()
Dim rng As Range, cell As Range, mtx(), i As Long
Set rng = Selection
ReDim mtx(1 To 2, 1 To rng.Rows.Count)
'Get uniques
i = 0
rng.AdvancedFilter Action:=xlFilterInPlace, Unique:=True
For Each cell In rng.SpecialCells(xlCellTypeVisible)
i = i + 1
mtx(1, i) = cell.Value
If i > 1 Then
If mtx(1, i) = mtx(1, i - 1) Then
mtx(1, i) = ""
i = i - 1
End If
If mtx(1, i) = "" Then i = i - 1
End If
Next cell
ReDim Preserve mtx(1 To 2, 1 To i)
rng.AdvancedFilter Action:=xlFilterInPlace, Unique:=False
'Check length
For Each cell In rng
For i = 1 To UBound(mtx, 2)
If cell.Value = mtx(1, i) Then
If IsEmpty(mtx(2, i)) Then
mtx(2, i) = Len(cell.Offset(, 1))
Else
If Len(cell.Offset(, 1).Value) <> mtx(2, i) Then
mtx(2, i) = -1
Exit For
End If
End If
End If
Next i
Next cell
'Set colour
For Each cell In rng
For i = 1 To UBound(mtx, 2)
If cell.Value = mtx(1, i) Then
If mtx(2, i) = -1 Then cell.Interior.Color = 65535
Exit For
End If
Next i
Next cell
End Sub
Select the range (A4:A18) then run the macro.
You don't even need to sort the data first, look at my attached file, and try to run at range A23:A39.
Regards
Bookmarks