Display unique values in a range.
this code only looks to see if a value is unique to its previous value.
any way to see if it is unique to all previous values?
Sub Unique()
Dim cLastRow As Long
Dim i As Long
Dim j As Long
Dim prevVal
cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
prevVal = ""
For i = 1 To cLastRow
If Cells(i, "A").Value < prevVal Then
j = j + 1
Cells(j, "B").Value = Cells(i, "A").Value
prevVal = Cells(i, "A").Value
End If
Next i
End Sub
|