View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1977_] Rick Rothstein \(MVP - VB\)[_1977_] is offline
external usenet poster
 
Posts: 1
Default How to Populate an Array with a Discontiguous Values

Thanks for catching that Alan.

<<Note to self: Test **before** you post!

Rick


"Alan Beban" wrote in message
...
Rick Rothstein (MVP - VB) wrote:
I guess you could do this...

Dim MyArray()
MyArray = Array(1, 2, 3, , , , 7, 8, 9)

. . . If you declare your array with an actual type (Integer, Long,
String, etc.), then elements 4, 5, and 6 will take on the default value
for those data types (0, 0, "", etc.).

Rick


No. You will get a Type mismatch error.

Alan Beban


"PMC1" wrote in message
...

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