Hi all
The following works to extract unique values from a column.
But, it does not work for a filtered column. I need to filter a column then get only the remaining unique values.
Can someone suggest how to make this work please.
Sub UniqueValues()
Dim WSOrigin As Worksheet
Dim dic As Object
Dim i As Long
Dim arrRangeArray As Variant
Dim arrDicArray As Variant
'Set sheet variables
Set WSOrigin = Worksheets("ReportDownload")
LastRow = WSOrigin.Range("U" & Rows.Count).End(xlUp).Row
'Create a dictionary object
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = vbTextCompare
'Pass the column to an array
arrRangeArray = WSOrigin.Range("U2:U" & LastRow)
'Loop
For i = LBound(arrRangeArray) To UBound(arrRangeArray)
If arrRangeArray(i, 1) <> "" Then dic(arrRangeArray(i, 1)) = Empty
Next i
'Return uniques
arrDicArray = dic.keys
'Confirm
For i = 0 To UBound(arrDicArray)
Debug.Print arrDicArray(i)
Next i
End Sub
Cheers
Bookmarks