View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
David Empey David Empey is offline
external usenet poster
 
Posts: 4
Default How do I Create 'ragged' arrays in Excel VBA?

The following code seems to work, but is it safe?

Sub RaggedArray

Dim A() as Variant, B() as Long, i as Long, j as Long

ReDim A(1 to 10)
For i = 1 to 10
ReDim B(1 to I)
A(i) = B
For j = 1 to i
A(i)(j) = 10 * i + j
Next j
Next i

End Sub

This seems to create an array A whose elements are arrays
of varying lengths, which is what I want, but can I be
sure the elements of A won't be overwritten by some other
piece of code that needs to use memory? Does Visual
Basic know the elements of A exist?

Am I even asking a sensible question?

--
Dave Empey

Remember, if you're doing any major experiments in stellar
dynamics, always mount a scratch star first! --Richard Todd