Array in VBA

  • Thread starter Thread starter Piotr
  • Start date Start date
P

Piotr

Hi
How can I change the size of array in VBA ?
Is it possible to change static array or dynamic array ?
Please, help me.

THANKS !

Best regards,
Piotr
 
Dim ary, i

ReDim ary(1 To 5)
For i = 1 To 5
ary(i) = i
Next i
MsgBox ary(5)

ReDim Preserve ary(1 To 6)
ary(6) = 6
MsgBox ary(5)
MsgBox ary(6)
 
Dynamic array, yes; static array, no. What do you want to change? From
what to what?

Alan Beban
 
In one dimension there is no problem.
If I have twoj dimensions or more... I lose my data - but If I use ReDim
Preserve I won't lost data only in the last dimension ?
Is there any other possibilities ?

Best regards,
Piotr :-)
 
Let me try again. What do you want to change from what to what? Perhaps
you could give a simple illustration of what you are trying to achieve
in a two-dimensional array.

Alan Beban
 
Hi Alan
I havn't any real problem - I learn VBA and I'd like to know all
possibiliteis about changing size of arrays. Sorry if my questions are
stupid :-(

Best regards,
Piotr
 
No, no! Not stupid at all. I'm just trying to get a fix on exactly what
you are trying to accomplish.

You might want to review the Sub Procedure ResizeArray in the freely
downloadable file at http://home.pacbell.net/beban

Alan Beban
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top