
Originally Posted by
YasserKhalil
I want to edit that function to be able to get unique values and to be sorted ..
The sort should be based on Column A
Use in cell like
=IFERROR(UniqNonBlank($A$1:$C$18,1,ROW(A1),COLUMN(A1)),"")
then copy right and down.
2nd argument, 1, is the key column for sort.
Function UniqNonBlank(rng As Range, sortCol As Long, ref As Long, col As Long)
Dim a, i As Long, ii As Long, txt As String, w
a = rng.Value: ReDim w(1 To UBound(a, 2))
With CreateObject("System.Collections.SortedList")
For i = 1 To UBound(a, 1)
txt = a(i, sortCol)
For ii = 1 To UBound(a, 2)
If ii <> sortCol Then txt = txt & Chr(2) & UCase$(a(i, ii))
w(ii) = a(i, ii)
Next
If (Len(Replace(txt, Chr(2), "")) > 0) * (Not .Contains(txt)) Then
.Item(txt) = w
End If
Next
UniqNonBlank = .GetByIndex(ref - 1)(col)
End With
End Function
Bookmarks