Hi,
How do I declare a multidimensional array [2--way] in VBA..??
thanks..
asingh
Hi,
How do I declare a multidimensional array [2--way] in VBA..??
thanks..
asingh
Depends upon how you want to populate it.
You can dimension it in the declaration
[vba]
Dim ary(1 To 3, 1 To 5)
[/vba]
or just declare it as variant and redim later
[vba]
Dim ary
ReDim ary(1 To 3, 1 To 5)
[/vba]
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
You can also declare it as a specific datatype in the Dim statement, or declare as a variant and then specify the type in the Redim. You cannot however declare an array as one type in the Dim statement and then change type in the Redim.
Regards,
Rory
Microsoft MVP - Excel
Or you could define a UDT then declare an array as that (saves memory)
2+2=9 ... (My Arithmetic Is Mental)
Currently just for interests sake, what's a UDT?
It's a User Defined Type. And while you could do that, I don't know why you would in most cases.
Regards,
Rory
Microsoft MVP - Excel
Nor I. They are a good idea that has been badly implemented, so personally I avoid them. I would use a class over a UDT every time.
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Likewise, though I believe the VB.Net and VB 2005 implementation of them (structures) is much better.
Regards,
Rory
Microsoft MVP - Excel
thanks...all...!
regards, asingh