Hello kapilrakh,
This macro will print the your list of unique strings in a single column on a worksheet and sort them in ascending order.
Sub ListUniques(Where As Range, ByVal StrArray As Variant)
Dim MyList As Object
Dim Str As Variant
Set MyList = CreateObject("Scripting.Dictionary")
MyList.CompareMode = vbTextCompare
For Each Str In StrArray
If Str <> "" Then
If Not MyList.Exists(Str) Then MyList.Add Str, 1
End If
Next Str
Set Where = Where.Resize(RowSize:=MyList.Count)
Where = WorksheetFunction.Transpose(MyList.Keys)
Where.Sort Key1:=Where.Cells(1, 1), Order1:=xlAscending, Header:=xlNo, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Set MyList = Nothing
End Sub
Example of Using the Macro
This will copy the list to the Active Sheet. Starting in Cell "A1".
ListUniques Range("A1"), Str1
Bookmarks