CountArrayCol

Returns the count of array fields, given the dimension, using UBound
Replacement function for UBound (has extra functionality and error handling)

Function CountArrayCol(avValues As Variant, Optional lDimension As Long = 1, Optional lDefault As Long = -1) As Long
' Purpose : Replacement function for UBound (has extra functionality and error handling)
' Inputs : avValues The array to find the UBound.
' lDimension Which dimension's upper bound to return
' [lDefault] The value to return if an error occurs
' Outputs : The upper bound of the array, or lReturnThis if an error occurs
 CountArrayCol = lDefault
 On Error Resume Next
 CountArrayCol = UBound(avValues, lDimension)
 On Error GoTo 0
End Function

avValues As Variant, Optional lDimension As Long = 1, Optional lDefault As Long = -1

Example: CountArrayCol(Arr(), 2)

Views 193 Downloads 58


ANmarAmdeen
612
Attachments
Math VBA
Revisions

v1.0