LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Array data to Range: Only first value written

I have created an array that stores prices. When my code writes the values
of the array (single dimension, about 1500 elements), it writes the value of
the first element to every cell of the worksheet range. Relevant code is as
follows:

Dim Px As Single, EMA_0 As Single, EMA_1 As Single
Dim arEMA() As Single

nData = UBound(arPxData())
ReDim arEMA(nData)

arEMA(1) = arPxData(1)
For i = 2 To nData
arEMA(i) = (2 / (1 + nPeriods) * (arPxData(i) - arPxData(i - 1))) +
arPxData(i - 1)
Next

With Range("OutEMA0Head")
Range(.Offset(1, 0), .Offset(nData, 0)).Clear
Range(.Offset(1, 0), .Offset(nData, 0)) = arEMA
End With

The Watch window shows that each element of the arEMA is filled with
different values. The .Clear line works perfectly. So does = arEMA line,
except all 1500 cells are filled with the same value - the first element of
arEMA.

I don't want to have to loop through every cell, but it makes no sense to me
why this is happening.

Any suggestions would be appreciated.



 
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
Using a Formula to get Range of Data to an Array Chris Paterson Excel Programming 2 September 16th 05 05:08 PM
Q: Best way to take data from VBA into graphs without writing data to worksheets? (Can a named range refer to an array in memory only?) KR Excel Programming 2 December 16th 04 11:12 PM
Read Range Data into Array Stratuser Excel Programming 1 April 26th 04 06:46 PM
Searching range for value (code written but needs 'tweaking'!) ian123[_26_] Excel Programming 8 December 23rd 03 05:19 PM
How to protect single cell or cells range from being over-written? Michael[_15_] Excel Programming 1 October 1st 03 04:50 AM


All times are GMT +1. The time now is 12:34 PM.

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

About Us

"It's about Microsoft Excel"