Load a two-dimensional array from two independent ranges

Hi,,

I know how to define arrays and two dimensional, and place data in them, however how do I preload two dimensional arrays using ranges from different parts of the sheet, i.e C8:C1000 and P8:P1000

Ta
MirageSFAsked:
Who is Participating?
 
Rgonzo1971Commented:
Hi,

pls try
Dim rng1, rng2
rng1 = Range("C8:C1000")
rng2 = Range("P8:P1000")

Open in new window

Regards
0
 
Bill PrewCommented:
And if trying to put that all in a single array then perhaps:

Dim rng1(2)
rng1(0) = Range("C8:C1000")
rng1(1) = Range("P8:P1000")

Open in new window


»bp
0
 
Martin LissOlder than dirtCommented:
Dim MyArray()
Dim rng As Range

Set rng = Application.Union(Range("C8:C1000"), Range("P8:P1000"))
MyArray = rng

Open in new window

0
 
Bill PrewCommented:
And I believe you can also do:

Dim rng1
rng1 = Union(Range("C8:C1000"), Range("P8:P1000"))

Open in new window


»bp
0
 
Bill PrewCommented:
Not worth an objection, but I would have preferred an equal distribution of the points.


»bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.