How to insert a lot of values into cells?

  • Thread starter Thread starter siedem
  • Start date Start date
S

siedem

Hi

I have DataTable with data. I would like to insert them into Excel
worksheet. Now I'm doing this cell by cell in two loop (for). Can it be done
faster?

thanks in advance
P.
 
siedem said:
*Hi

I have DataTable with data. I would like to insert them into Excel
worksheet. Now I'm doing this cell by cell in two loop (for). Can i
be done
faster?

thanks in advance
P. *

Hi siedem,

If the data is an arrayi2-D), you can input them to cells more fast.
If an array is 1-D, make it as 2-D, or us
Application.transpose(array).

Example:


Code
-------------------

Sub Test()
Dim arrayData(1 To 1000, 1 To 1) As Long
Dim i As Long

'Make a sample array
For i = 1 To 1000
arrayData(i, 1) = i
Next

'Input an array into cells.
Cells(1, 1).Resize(UBound(arrayData, 1), UBound(arrayData, 2)).Value = arrayData
End Sub
 
Look at the copy from recordset method of the range object. works with DAO
only in xl97, but with DAO and ADO in later versions.
 
Back
Top