Hi,
I am trying to transfer a fairly large array from an external program to an Excel sheet via VBA in one go. However, simply assigning an array to an Excel range as in the proto example below does not do the job, as all cells are filled with the array's lower bound. Specifying an array index obviously does not help either. I tried all sorts of different options from within Excel to first get it straight there, but to no avail...
This is EEG data and there are lots, lots, lots of channels and timepoints, so I need all the speed I can get and loops just simply are toooo slow.
Question: Is there any way to assign a whole array to an Excel range object at once and without having to go through loops?
TIA,
ramgni
------------- snip -------------------------------
Sub Main
Dim ExcelApp As Object
Set ExcelApp = CreateObject("Excel.Application"
ExcelApp.Visible = True
ExcelApp.WorkBooks.Add
Dim MyArray(1 To 20) As Double
For MyArrayNum = 1 To 20
MyArray(MyArrayNum) = MyArrayNum
Next MyArrayNum
ExcelApp.Activesheet.Range("A1:A20".Value = MyArray
End Sub
------------- snip -------------------------------
I am trying to transfer a fairly large array from an external program to an Excel sheet via VBA in one go. However, simply assigning an array to an Excel range as in the proto example below does not do the job, as all cells are filled with the array's lower bound. Specifying an array index obviously does not help either. I tried all sorts of different options from within Excel to first get it straight there, but to no avail...
This is EEG data and there are lots, lots, lots of channels and timepoints, so I need all the speed I can get and loops just simply are toooo slow.
Question: Is there any way to assign a whole array to an Excel range object at once and without having to go through loops?
TIA,
ramgni
------------- snip -------------------------------
Sub Main
Dim ExcelApp As Object
Set ExcelApp = CreateObject("Excel.Application"
ExcelApp.Visible = True
ExcelApp.WorkBooks.Add
Dim MyArray(1 To 20) As Double
For MyArrayNum = 1 To 20
MyArray(MyArrayNum) = MyArrayNum
Next MyArrayNum
ExcelApp.Activesheet.Range("A1:A20".Value = MyArray
End Sub
------------- snip -------------------------------