How to write an array to a range without looping
I would use something like this:
Option Explicit
Sub testme()
Dim myArr(1 To 5, 1 To 3) As Long
Dim rCtr As Long
Dim cCtr As Long
Dim DestCell As Range
'test data only
For rCtr = LBound(myArr, 1) To UBound(myArr, 1)
For cCtr = LBound(myArr, 2) To UBound(myArr, 2)
myArr(rCtr, cCtr) = rCtr * cCtr
Next cCtr
Next rCtr
Set DestCell = Worksheets("Sheet1").Range("a1")
DestCell.Resize(UBound(myArr, 1) - LBound(myArr, 1) + 1, _
UBound(myArr, 2) - LBound(myArr, 2) + 1).Value _
= myArr
End Sub
On 04/26/2011 07:18, Andy wrote:
Hello,
I have an array MyArray(10000,3), and I want to write this into sheet
1 starting at row 1 col 1. I would like to do it without using a for
loop or a counter. I am looking for a way to paste the entire array
at once. The reason for this is processing speed. A for loop takes a
while when the array gets large.
thanks,
Andy
--
Dave Peterson
|