scrib3
04-12-2013, 11:12 PM
hi
i have been given 3 conditions to apply to 6 stocks in an array(10,6) with their returns for 10 years. the first being, if there are 3 other negative returns for the same year and that year happens to be negative then return "message1" in a corresponding array(10,6). and any other positive returns for that year should return "message2". But if there are less than 3 other negative returns in that year across all 6 stocks and the particular stock is less than -2% than it should return "message3". and if there are less than 3 other negative returns in that year across all 6 stocks and the particular stock is greater than 5% than it should return "message4"
my attempt:
Dim arraytwo() As Double
ReDim arraytwo(noRows, noCols) As Double
For i = 1 To noRows
For j = 1 To noCols
arraytwo(i, j) = Range("input").Cells(i, j)
If arraytwo(i, 1) < 0 Then
d_one = d_one + 1
End If
If arraytwo(i, 1) < 0 And d_one > 3 Then
Range("output").Cells(i, 1) = "message1"
ElseIf arraytwo(i, 1) > 0 And d_one > 3 Then
Range("output").Cells(i, 1) = "message2"
ElseIf arraytwo(i, 1) < -0.02 Then
Range("output").Cells(i, 1) = "message3"
ElseIf arraytwo(i, 1) > 0.05 Then
Range("output").Cells(i, 1) = "message4"
End If
any help would be much appreciated
i have been given 3 conditions to apply to 6 stocks in an array(10,6) with their returns for 10 years. the first being, if there are 3 other negative returns for the same year and that year happens to be negative then return "message1" in a corresponding array(10,6). and any other positive returns for that year should return "message2". But if there are less than 3 other negative returns in that year across all 6 stocks and the particular stock is less than -2% than it should return "message3". and if there are less than 3 other negative returns in that year across all 6 stocks and the particular stock is greater than 5% than it should return "message4"
my attempt:
Dim arraytwo() As Double
ReDim arraytwo(noRows, noCols) As Double
For i = 1 To noRows
For j = 1 To noCols
arraytwo(i, j) = Range("input").Cells(i, j)
If arraytwo(i, 1) < 0 Then
d_one = d_one + 1
End If
If arraytwo(i, 1) < 0 And d_one > 3 Then
Range("output").Cells(i, 1) = "message1"
ElseIf arraytwo(i, 1) > 0 And d_one > 3 Then
Range("output").Cells(i, 1) = "message2"
ElseIf arraytwo(i, 1) < -0.02 Then
Range("output").Cells(i, 1) = "message3"
ElseIf arraytwo(i, 1) > 0.05 Then
Range("output").Cells(i, 1) = "message4"
End If
any help would be much appreciated