Array <--- Range
Things can be speeded up considerably, however, by looping in memory
rather than looping to the range. E.g.,
Sub Foo()
Dim rngTest As Range, saTest() As String, srTest As Variant
Set rngTest = ThisWorkbook.Names("Test").RefersToRange
ReDim saTest(1 To rngTest.Rows.Count, 1)
srTest = rngTest
For i = 1 To rngTest.Rows.Count
saTest(i, 1) = srTest(i, 1)
Next
End Sub
Alan Beban
Alan Beban wrote:
"Charley Kyd" wrote
Dim rngTest As Range, saTest() As String . . .
So, can anyone suggest a way to load an array with values from a
range--without looping?
Charles Williams wrote:
Sub Bar(rngTest as range)
dim vArray as variant
dim j as long
vArray=rngTest
for j=1 to 3
msgbox vArray(j,1)
next j
end sub
Charley Kyd's array is type String(). It can't be loaded directly from
a worksheet range without looping.
Alan Beban
|