Assign a range directly to an arry in Excel
I'm trying to do something that seems simple, but is throwing an error. I have a range with a definite number of values and I'm trying to stick those values in an array without having to iterate through each cell. The code is:
Code:
Dim Zip(43191)
Zip = Range("a2:a43192").Value
I get an error saying Cannot Assign to Array. I know all the values are there in that particular range of cells. This worked in past versions. I thought I heard that VBA changed the array assignment methods, so am I maybe doing it wrong now?
Thanks - E
Re: Assign a range directly to an arry in Excel
you can assign a range (as a 2 dimensional array) to a variant
vb Code:
dim zip as variant
Zip = Range("a2:a43192")
a single column will still be a 2d array