Hi Yasser,
See how this goes:
Option Explicit
Sub Macro1()
Dim strNums() As String
Dim strLineOfNums As String
Dim i As Long, j As Long, k As Long
Dim lngCountOfChar As Long, lngLenOfChar As Long
Dim lngMyRow As Long
Dim blnInclude As Boolean
Application.ScreenUpdating = False
For lngMyRow = 2 To Cells(Rows.Count, "A").End(xlUp).Row
blnInclude = False
strLineOfNums = Replace(Range("A" & lngMyRow), "-", "")
strNums = Split(Range("A" & lngMyRow), "-")
For i = LBound(strNums) To UBound(strNums)
For j = 1 To Len(strNums(i))
lngLenOfChar = Len(strNums(i))
lngCountOfChar = 0
For k = 1 To lngLenOfChar
lngCountOfChar = lngCountOfChar + Len(strLineOfNums) - Len(Replace(strLineOfNums, Mid(strNums(i), k, 1), ""))
Next k
'If each digit in the number is only in the string once i.e. the count of each digit is equal to the length of the number, then...
If lngLenOfChar = lngCountOfChar Then
'...exit the loop as it's unique and we want the string in our results
blnInclude = True
Exit For
End If
Next j
Next i
'If the string is to be included in our results, then...
If blnInclude = True Then
'...colour rhe cell green (change to suit)
Range("A" & lngMyRow).Interior.Color = RGB(0, 255, 0)
End If
Next lngMyRow
Application.ScreenUpdating = True
End Sub
Regards,
Robert
Bookmarks