We help IT Professionals succeed at work.

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
Comment
Watch Question

Top Expert 2016
Commented:
Hi,

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

Open in new window

Regards
Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016
Commented:
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
Martin Liss"There is still no cure for the common birthday." ~John Glenn
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Dim MyArray()
Dim rng As Range

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

Open in new window

Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016

Commented:
And I believe you can also do:

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

Open in new window


»bp
Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016

Commented:
Not worth an objection, but I would have preferred an equal distribution of the points.


»bp