ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dynamic Array (https://www.excelbanter.com/excel-programming/289194-dynamic-array.html)

dan

Dynamic Array
 
How can I tell if an array declared initially as myArray() has yet been ReDim'ed?

Chip Pearson

Dynamic Array
 
Dan,

You can test the lower or upper bound and trap the error that
occurs if the array isn't dim'd. E.g,

Dim N As Long
On Error Resume Next
N = LBound(Arr,1)
If Err.Number = 9 Then
Debug.Print "Arr not dim'd"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"dan" wrote in message
...
How can I tell if an array declared initially as myArray() has

yet been ReDim'ed?



dan

Dynamic Array
 
Thanks Chip - already coded that I was hoping for a more elegant solution - oh wel

Thanks again

Dana DeLouis[_3_]

Dynamic Array
 
Just another idea then...

Sub Demo()
Dim v As Variant
' etc
If Not IsArray(v) Then ReDim v(1 To 10)
End Sub


--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"dan" wrote in message
...
Thanks Chip - already coded that I was hoping for a more elegant

solution - oh well

Thanks again




Alan Beban[_4_]

Dynamic Array
 
OP wrote
--How can I tell if an array declared initially as myArray() has yet
been ReDim'ed?


Dana DeLouis wrote:
Just another idea then...

Sub Demo()
Dim v As Variant
' etc
If Not IsArray(v) Then ReDim v(1 To 10)
End Sub



If it has been ReDim'ed (e.g., 1 to 5) then this code won't disclose that.

Alan Beban



All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com