1 Attachment(s)
vba - Extract Unique values from Single Column via Colllection and Dictionary
Code:
Hi Team,
Need vba collection and dictionary help for extracting unique values of Single Column and pasting in Range(d2") via Dictionary
and Range("h2") via Collection
Unique values should be excluding blank. Below is my attempted Code not working.
Sub Unique_List_via_Collection()
Dim lr As Long
Dim i As Long
Dim Coll As New Collection
lr = Range("a65000").End(xlUp).Row
For i = 2 To lr
If Range("a" & i).Value <> "" Then
On Error Resume Next
Coll.Add Range("A" & i).Value, Range("A" & i).Value
On Error GoTo 0
End If
Next i
getting error at below line.
Range("d2").Resize(Coll.Count).Value = Application.WorksheetFunction.Transpose(Coll.Items)
End Sub
Thanks in advance for help.
Regards,
mg