Hi Yasser,
I know you have a working solution but it bothers me that I can't get it right. Could you let me know how this goes:
Option Explicit
Sub Macro1()
Dim strNums() As String
Dim strLineOfNums As String
Dim i As Long, j As Long
Dim lngCountOfChar As Long, lngLenOfNum As Long
Dim lngMyRow As Long
Dim lngUniqueCount As Long
Application.ScreenUpdating = False
For lngMyRow = 2 To Cells(Rows.Count, "A").End(xlUp).Row
strNums = Split(Range("A" & lngMyRow), "-")
For i = LBound(strNums) To UBound(strNums)
If i = 0 Then
strLineOfNums = Replace(Range("A" & lngMyRow), strNums(i) & "-", "")
ElseIf i > 0 And i < UBound(strNums) Then
strLineOfNums = Replace(Range("A" & lngMyRow), "-" & strNums(i) & "-", "")
Else
strLineOfNums = Replace(Range("A" & lngMyRow), "-" & strNums(i), "")
End If
strLineOfNums = Replace(strLineOfNums, "-", "")
lngLenOfNum = Len(strNums(i))
For j = 1 To lngLenOfNum
lngCountOfChar = lngCountOfChar + Len(strLineOfNums) - Len(Replace(strLineOfNums, Mid(strNums(i), j, 1), ""))
Next j
If lngCountOfChar = 0 Then
lngUniqueCount = lngUniqueCount + 1
End If
lngCountOfChar = 0
Next i
'If there's found to be only 1 unique combination of a set of digits from a number, then...
If lngUniqueCount = 1 Then
'...colour rhe cell green (change to suit)
Range("A" & lngMyRow).Interior.Color = RGB(0, 255, 0)
End If
lngUniqueCount = 0
Next lngMyRow
Application.ScreenUpdating = True
End Sub
Thanks,
Robert
Bookmarks