Flávio Ravier
Flávio Ravier

Reputation: 1

copy a range to a defined array

how to copy a range to a already defined array?

Dim l1(71, 6) As Variant
l1 = wsTEMP.Range("g3:m72").Value

this does not work!

Upvotes: 0

Views: 42

Answers (1)

user4039065
user4039065

Reputation:

If you wnt to retain the dimensions you've declared the array at, resize the source according to the initial array.

Dim l1(1 to 71, 1 to 6) As Variant

l1 = wsTEMP.Range("g3").resize(ubound(l1 , 1), ubound(l1 , 2)).Value

Stuffing worksheet cells into a variant array always creates a one-based, 2-D array. You cannot change that.

Upvotes: 1

Related Questions