Is there any built-in functionality in vba to get unique values from a one-dimensional array? What about just getting rid of duplicates?
If not, then how would I get
There is no VBA built in functionality for removing duplicates from an array, however you could use the next function:
Function RemoveDuplicates(MyArray As Variant) As Variant
With CreateObject("scripting.dictionary")
For Each item In MyArray
c00 = .Item(item)
Next
sn = .keys ' the array .keys contains all unique keys
MsgBox Join(.keys, vbLf) ' you can join the array into a string
RemoveDuplicates = .keys ' return an array without duplicates
End With
End Function