You can write a single procedure that accepts any type of array as an argument by using a variantparameter. Within the procedure, address the array using the usual syntax:
' return the number of itemsFunction ItemCount(anArray As Variant) _ As LongItemCount = UBound(anArray) - _ LBound(anArray) + 1' the first element is ' anArray(LBound(anArray))End Function
You can even pass a matrix with any number of dimensions; in order to understand how many dimensions,you must iterate on the UBound or LBound functions until an error occurs:
Function ItemCount(anArray As Variant) _ As LongDim items As Long, i As IntegerOn Error Resume Nextitems = UBound(anArray) - _ LBound(anArray) + 1For i = 2 to 999 items = items * (UBound(anArray, _ i) - LBound(anArray, i) + 1) If Err Then Exit ForNextItemCount = itemsEnd Function