Is there a way to find out if a subscript is out of range in an array?
Printable View
Is there a way to find out if a subscript is out of range in an array?
You can trap specific error number in some error handler but what are you trying to do?
Yep, use LBound() and UBound() to determine the valid subscript range.
Code:If YourSubscript < LBound(TheArray) Or YourSubscript > UBound(TheArray) Then
MsgBox "Out of Range", vbExclamation
End If
Assuming that's what you meant, you can also use those commands with multi-dimensioned arrays.
[code]
dim MyArray(5, 13) as boolean
msgbox ubound(myarray, 2)