CountArrayCol

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


Public

Not Tested

Not My Work
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 678 Downloads 185

VBA Math
ANmarAmdeen
659
Attachments
Revisions

v2.0