Is there a vba command to get directly a list without duplicates from the header autofilter of a list object.
My input is this list and I search a way to get this list without duplicates from my object ListObject in vba
Thanks in advance.
Is there a vba command to get directly a list without duplicates from the header autofilter of a list object.
My input is this list and I search a way to get this list without duplicates from my object ListObject in vba
Thanks in advance.
you could use this helper function:
Function GetUniqueValues(rng As Range) As Variant
Dim cell As Range
With CreateObject("Scripting.Dictionary")
For Each cell In rng
.Item(cell.Value) = 1
Next
GetUniqueValues = .keys
End With
End Function
to be called by your "main" module as follows:
Option Explicit
Sub main()
Dim uniqueValues As Variant
uniqueValues = GetUniqueValues(ActiveSheet.ListObjects(1).ListColumns(1).DataBodyRange)
'... rest of your code
End Sub
just change ActiveSheet
, ListObjects(1)
and ListColumns(1)
references as per your needs