View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban[_2_] Alan Beban[_2_] is offline
external usenet poster
 
Posts: 783
Default How to Populate an Array with a Discontiguous Values

PMC1 wrote:
Hi,

Using Excel 2003 VBA I'm looking to Populate a 1 dimensional Array
with a Discontiguous values.

For example, instead of fully declaring a range like this
Array(1,2,3,7,8,9) I want ot pupulate the array by declaring the range
and then use something like a loop to populate the array e.g.

Dim myArRanges(1 to 3, 7 to 9)
Redim MyArray(myArRanges)

Could anyone suggest how this might be done.

Thanks

..pc

I'm not 100% sure I know what you are asking, but if the functions in
the freely downloadable file at http://home.pacbell.net/beban are
available to your workbook, then with 1,2,3,4,5,6,7,8,9 in A1 to A9, The
following will generate a 1-D array of six elements: 1,2,3,7,8,9

Dim rng As Range
Dim MyArray() As Integer 'or Variant or Long or Single or Double or 'Byte
Set rng = Range("a11:a13,a17:a19")
Assign rng, MyArray

Alan Beban