This isn't eligant but it is pretty straight forward. Use split to put
the numbers into an array. Perform a Buble Test on the array by
comparing each element with all the other element. If a duplicate is
found then put replace the number with an X. Then remove all the
numbers from the array.
Chip Pearson has some solutions for counting the duplicates and non
duplicate in the string. He also has methods for getting duplices when
each number is in a seperate cells. You could use TexttoColumn method
and then use one of Chip's solutions. If you where going to use
TextTocolumns I would then use Advance filter to get unique values.
Sub test()
'Date in cells with spaces are treat as string
'Use the line below for testing
MyArray = "1 18 22 5 1 31 8 11 6 1"
NumberArray = Split(MyArray, " ") 'split line around spaces
For i = LBound(NumberArray) To UBound(NumberArray)
'remove any spaces in the number
NumberArray(i) = Val(Trim(NumberArray(i)))
Next i
'replace all duplicates with empty string
For i = LBound(NumberArray) To (UBound(NumberArray) - 1)
For j = (i + 1) To UBound(NumberArray)
If NumberArray(i) = NumberArray(j) Then
NumberArray(j) = "X"
End If
Next j
Next i
MyArray = ""
For i = LBound(NumberArray) To UBound(NumberArray)
If NumberArray(i) < "X" Then
If MyArray = "" Then
MyArray = NumberArray(i)
Else
MyArray = MyArray & " " & NumberArray(i)
End If
End If
Next i
End Sub
--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=170687
Microsoft Office Help