array variable is empty?
Sub CCC()
Dim arIntArray() As Integer
Dim ub As Long, res As Variant
If Rnd() < 0.5 Then _
ReDim arIntArray(1 To 5)
On Error Resume Next
ub = UBound(arIntArray)
res = Err.Number
On Error GoTo 0
If res < 0 Then
' not dimmed
MsgBox "Not Dimensioned"
Else
' process the array
MsgBox "Dimensioned"
End If
End Sub
--
Regards,
Tom Ogilvy
"mark" wrote:
Hi.
Pretend I have an integer array variable that I'm using for somthing,
arIntArray()
There's a loop that goes through and populates the elements of that array,
which are a subset of the columns in the spreadsheet.
If it turns out that there aren't any columns which meet the condition which
populates the array, is there a quick way to determine that the array is
still empty?
Ubound(arIntArray) fails, becuase it's undefined. Is Nothing and Null also
produced errors.
If needed, I can put in a Boolean flag to set if the array gets populated,
but it seems like there is likely another way.
Thanks.
Mark
|