View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Getting results from VBA calculations into cells

You can assign an array to a range in one step. The array must be two
dimensional:

Dim vMyArray As Variant
Dim i As Long
ReDim vMyArray(1 To 10, 1 To 1)
For i = 1 To 10
vMyArray(i, 1) = i
Next i
Range("A1:A10").Value = vMyArray

Note that using Application.Transpose coerces a 1-dimensional array to
two dimensions:

Dim nMyArray(1 To 10) As Long
Dim i As Long
For i = 1 To 10
nMyArray(i) = i
Next i
Range("A1:A10").Value = Application.Transpose(nMyArray)

In article ,
Richard Owlett wrote:

I have an existing VisualBasic routine which reads some data files and
prints results to a file.

I have been then importing them to Excel to use it plot feature.

Realized I could do whole thing in Excel.

Before lunch, I found appropriate reference in Help which had comments
on doing a sequence of calculations and placing them sequential cells.

It's after lunch, and I can't find the reference.
[It had a caution about referencing cells as an array rather than
A1..A23 etc.]

Could someone point me back in right direction.
Using ( too infrequently Excel 97)
Thanks