Assigning Range to Array

G

Guest

I often assign ranges to two-dimensional arrays. I've noticed that I can do
it by declaring the variable as a variant variable, or as an array of
variants. It seems to work either way. Which of these two is better?

Dim MyArray as Variant
MyArray = Range("MyRange").Value

or

Dim MyArray() As Variant
MyArray = Range("MyRange").Value
 
A

Alan Beban

I'm not certain, but I think the second fails in versions prior to xl2000.

Alan Beban
 
M

Myrna Larson

I think you may be correct. I was thinking, too, that to assign data to
elements of a "normal" array you had to do it cell by cell, with a loop.
 
A

Alan Beban

Myrna said:
I think you may be correct. I was thinking, too, that to assign data to
elements of a "normal" array you had to do it cell by cell, with a loop.
No, not if it's declared as a dynamic array.

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

Top