Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cells do not show results of calculations the commissioner Excel Discussion (Misc queries) 2 November 14th 08 04:38 AM
Conditional Calculations with Calculated Results Koneko Excel Worksheet Functions 1 March 28th 08 11:13 PM
N/A results on vlookup with time calculations Freida Excel Worksheet Functions 4 October 22nd 07 06:09 PM
Copying formulas without changing previous results/calculations kate_suzanne Excel Worksheet Functions 6 August 28th 06 03:46 AM
Help on performing calculations on formula results AussieExcelUser Excel Worksheet Functions 3 March 14th 06 08:01 AM


All times are GMT +1. The time now is 11:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"