November 20, 1999

FilterDuplicates – Delete duplicate items in an array

‘ Filter out duplicate values in an array and compact’ the array by moving items to “fill the gaps”.’ Returns the number of duplicate values” it works with arrays of any type, except objects” The array is not REDIMed, but you can do it easily using’ the following code:’ a()

HasDuplicateValues – Check if an array has duplicate values

‘ Returns True if an array contains duplicate values’ it works with arrays of any typeFunction HasDuplicateValues(arr As Variant) As Boolean Dim col As Collection, index As Long Set col = New Collection ‘ assume that the array contains duplicates HasDuplicateValues = True On Error GoTo FoundDuplicates For index =

ArrayShuffle – Randomize the order of elements in an array

‘ Shuffle the elements of an array of any type’ (it doesn’t work with arrays of objects or UDT)Sub ArrayShuffle(arr As Variant) Dim index As Long Dim newIndex As Long Dim firstIndex As Long Dim itemCount As Long Dim tmpValue As Variant firstIndex = LBound(arr) itemCount = UBound(arr) – LBound(arr)

ArraySum – The sum of all the items in an array of any type

‘ Return the sum of the values in an array of any type’ (for string arrays, it concatenates all its elements)” FIRST and LAST indicate which portion of the array’ should be considered; they default to the first’ and last element, respectivelyFunction ArraySum(arr As Variant, Optional First As Variant, _

ArrayAvg – The average of an array of any type

‘ The average of an array of any type” FIRST and LAST indicate which portion of the array’ should be considered; they default to the first’ and last element, respectively’ if IGNOREEMPTY argument is True or omitted,’ Empty values aren’t accounted forFunction ArrayAvg(arr As Variant, Optional First As Variant, _

ArrayStdDev – The standard deviation of a numeric array

‘ The standard deviation of an array of any type” if the second argument is True or omitted,’ it evaluates the standard deviation of a sample,’ if it is False it evaluates the standard deviation of a population” if the third argument is True or omitted, Empty values aren’t accounted