Put values into excel range from single dimension array

S

scottzuehl

I'm having a tough time getting all the values out of an array and into
an excel range. When I try to do it I only get the first value in the
array in all the cells in the range. Instead I want each element.
Here's the code:



Dim aSMASMA As Variant
Dim aTradedecision(1996) As Variant
Dim j As Integer
Dim element As Variant
Dim intTotaltradingdays As Integer


aSMASMA = Range("K5:L2000").Value
j = 0


For Each element In aSMASMA
If aSMASMA(j + 1, 2) <> Empty Then
aTradedecision(j) = aSMASMA(j + 1, 1) - aSMASMA(j + 1,
2)
j = j + 1
Else
Exit For
End If
Next

intTotaltradingdays = j

Range("M5").Resize(j).Value = aTradedecision()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top