Hi All,
I am a VBA newbie and want to find the unique values from a column and store them to an array.
I found this thread: https://www.mrexcel.com/forum/excel-questions/67144-filter-list-vba-array.html, and am trying out the post by dk with the following code:
For my project, I adapted the code to be:
However, I keep getting run-time error '1004': "This can't be applied to the selected range. Select a single cell in a range and try again."
Any thoughts or guidance?
I am a VBA newbie and want to find the unique values from a column and store them to an array.
I found this thread: https://www.mrexcel.com/forum/excel-questions/67144-filter-list-vba-array.html, and am trying out the post by dk with the following code:
Code:
Sub CopyToRange()
Dim Array1
Range("A1:A5474").AdvancedFilter Action:=xlFilterCopy, Unique:=True, CopyToRange:=Range("A6000")
Array1 = Range("A6000:A" & Range("A65536").End(xlUp).Row).Value
Range("A6000:A65536").Clear 'Get rid of the filtered data
End Sub
For my project, I adapted the code to be:
Code:
Sub Find_Uniques()
Dim Array1
Sheets("Map").Range("GM2:GM60000").AdvancedFilter Action:=xlFilterCopy, Unique:=True, CopyToRange:=Sheets("Map").Range("A6000")
Array1 = Range("A6000:A" & Range("A65536").End(xlUp).Row).Value
Range("A6000:A65536").Clear 'Get rid of the filtered data
End Sub
Any thoughts or guidance?