View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default Named Range to Array Oddity

Hi
then see Tom's reply

"bloycee" wrote:

I created the named range through the worksheet rather than VB so have
something like "MyNamedRange" is =Sheet1!$H$2:$K$13,Sheet1!$A$2:$D$21
from the Insert, Name, Define menu controls.

The assignment I tried was simply:

Dim MyArray as Variant

MyArray=Range("MyNamedRange").Value

This returned the data from cells H2 to K13 but not that in A2 to D21



Frank Kabel wrote:
Hi
could you provide the exact name definition and your assignment code.

Just as a guess: You have to use the areas collection to loop through

all
areas of your range

"bloycee" wrote:

I've just used a named range to fill an array and have found a
peculiarity that I'm not sure about. The named range was not
contiguous and when assigning it to the array the array only

appears to
have used the second section of the range. Is this what normally
happens and is there a work around?

If I gave each part of the original range a separate name could I

then
read them easily in to the same array? How?