![]() |
Getting results from VBA calculations into cells
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 |
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 |
Getting results from VBA calculations into cells
Thanks.
JE McGimpsey wrote: You can assign an array to a range in one step.[SNIP] 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) This isn't what I saw. BUT, is a much more *readable* approach. |
All times are GMT +1. The time now is 04:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com