Help with array. Cannot get values out of it

S

scottzuehl

I am trying to get the values out of 'buffprice' and 'buffdate' . When
I copy them to a range I only get the first value of each duplicated
down the entire range. How do I get each individual value?

thx


********************************************************
Dim v1 As Variant
Dim j2 As Variant

Dim j1 As Integer
Dim i1 As Integer
Static buffdecision(800) As Variant
Static buffdate(800) As Variant
Static buffprice(800) As Variant


Dim n As Variant
Dim nprice As Variant
Dim ndate As Variant


Dim v2 As Variant
Dim i2 As Integer
Dim v3 As Variant
Dim i3 As Integer


v1 = Range("M5:M2000").Value
v2 = Range("E5:E2000").Value
v3 = Range("A5:A2000").Value


j1 = 1
j2 = 2
n = 0




For i1 = LBound(v1, 1) To UBound(v1, 1)


If IsNumeric(v1(j1, 1)) Then
If (v1(j1, 1) > 0 And v1(j2, 1) < 0) Or (v1(j1, 1) <
0 And v1(j2, 1) > 0) Then

buffdecision(n) = v1(j1, 1)
buffprice(nprice) = v2(j1, 1)
buffdate(ndate) = v3(j1, 1)

n = n + 1
nprice = nprice + 1
ndate = ndate + 1


End If
j1 = j1 + 1
j2 = j2 + 1
End If

Next

Range("S5").Resize(j1 - 1).Value = buffdecision()
Range("S5").Resize(j1 - 1).Value = buffprice()
Range("T5").Resize(j1 - 1).Value = buffdate()
*************************************************************
 
J

Jim Cone

thx,

At first glance it appears that you need to change the orientation of
the arrays from horizontal to vertical...
buffdate(0 to 800, 1 to 1)
buffprice(0 to 800, 1 to 1)

Or you could just transpose them before transferring the values.

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


I am trying to get the values out of 'buffprice' and 'buffdate' . When
I copy them to a range I only get the first value of each duplicated
down the entire range. How do I get each individual value?

thx
********************************************************
Dim v1 As Variant
Dim j2 As Variant

Dim j1 As Integer
Dim i1 As Integer
Static buffdecision(800) As Variant
Static buffdate(800) As Variant
Static buffprice(800) As Variant
Dim n As Variant
Dim nprice As Variant
Dim ndate As Variant
Dim v2 As Variant
Dim i2 As Integer
Dim v3 As Variant
Dim i3 As Integer

v1 = Range("M5:M2000").Value
v2 = Range("E5:E2000").Value
v3 = Range("A5:A2000").Value
j1 = 1
j2 = 2
n = 0

For i1 = LBound(v1, 1) To UBound(v1, 1)
If IsNumeric(v1(j1, 1)) Then
If (v1(j1, 1) > 0 And v1(j2, 1) < 0) Or _
(v1(j1, 1) < 0 And v1(j2, 1) > 0) Then

buffdecision(n) = v1(j1, 1)
buffprice(nprice) = v2(j1, 1)
buffdate(ndate) = v3(j1, 1)

n = n + 1
nprice = nprice + 1
ndate = ndate + 1

End If
j1 = j1 + 1
j2 = j2 + 1
End If
Next

Range("S5").Resize(j1 - 1).Value = buffdecision()
Range("S5").Resize(j1 - 1).Value = buffprice()
Range("T5").Resize(j1 - 1).Value = buffdate()
*************************************************************
 
B

Bob Phillips

Dim v1 As Variant
Dim j2 As Variant

Dim j1 As Integer
Dim i1 As Integer
Static buffdecision(800, 0) As Variant
Static buffdate(800, 0) As Variant
Static buffprice(800, 0) As Variant


Dim n As Variant
Dim nprice As Variant
Dim ndate As Variant


Dim v2 As Variant
Dim i2 As Integer
Dim v3 As Variant
Dim i3 As Integer

v1 = Range("M5:M2000").Value
v2 = Range("E5:E2000").Value
v3 = Range("A5:A2000").Value

j1 = 1
j2 = 2
n = 0

For i1 = LBound(v1, 1) To UBound(v1, 1)

If IsNumeric(v1(j1, 1)) Then
If (v1(j1, 1) > 0 And v1(j2, 1) < 0) Or (v1(j1, 1) < 0 And
v1(j2, 1) > 0) Then

buffdecision(n, 0) = v1(j1, 1)
buffprice(nprice, 0) = v2(j1, 1)
buffdate(ndate, 0) = v3(j1, 1)

n = n + 1
nprice = nprice + 1
ndate = ndate + 1

End If
j1 = j1 + 1
j2 = j2 + 1
End If

Next

Range("S5").Resize(j1 - 1).Value = buffdecision()
Range("S5").Resize(j1 - 1).Value = buffprice()
Range("T5").Resize(j1 - 1).Value = buffdate()


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

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