Function RemoveDuplicates(InputArray as Variant, OutputArray as Variant) As Boolean
'Description: Removes duplicate values from a single-dimensional array
' and writes the result to another array
'Dependencies: Array Support module
' ZeroToOneBasedArray
Dim dic As Object
Dim key As Variant
Dim tempArr() As Variant
' Set the default result
RemoveDuplicates = False
' Ensure InputArray is an array.
If IsArray(InputArray) = False Then Exit Function
' Ensure InputArray is not empty.
If IsArrayEmpty(InputArray) Then Exit Function
' Ensure we have a single dimensional array
If NumberOfArrayDimensions(arr:=InputArray) <> 1 Then Exit Function
Set dic = CreateObject("Scripting.Dictionary")
For Each key In InputArray
dic(key) = 0
Next
' Convert to 1 based array, if needed (NB: dic.keys is always zero-based array)
If LBound(InputArray)=1 then
tempArr = ZeroToOneBasedArray(dic.keys)
Else
tempArr = dic.keys
End If
OutputArray = tempArr
RemoveDuplicates = True
End Function