Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50085

Trouble with getting a value

$
0
0
Hi guys,

I am working on a project in VBA and need a little help.
My formula does not generate a final value, could some


HTML Code:

Function test(A, B, T, Y0)

Dim sigma, n As Double

n = T / 10 * 10 * 10


ReDim SigOnemat(i, j)          'S_1 = rnd * B but should be different every time, not sure if this is the best way.
For i = 1 To n
j = 1
SOnemat(i, 1) = Rnd * B
Next

ReDim STwomat(i, j)          's_2 same story s_1
For i = 1 To n
j = 1
SOnemat(i, 1) = Rnd * B
Next


ReDim XMat(i, j)                'Vector with n rows and 1 colom
j = 1
For i = 1 To n
YMat = A + 0.5 * SOnemat(i, 1)  'Sigma_1 at same i needed
Next


ReDim YYmat(i, j)
j = 1
YYmat(1, 1) = Y0 'first Y
For i = 1 To n
YYmat(i + 1, 1) = YYmat(i, 1) + 0.5 * STwomat(i, 1) + 0.25 * XMat(i, 1) 'S_'2 at same i needed
Next



test = YYmat(n, 1)        'goal is to find the last value at (n,1) form YYmat



End Function

My own guess is that SOnemat and Stwomat are unnecessary (S_1 and S_2 could be sufficient). More than that I do not see why I can not get a value in excel.
Could someone tell me what I am doing wrong?

Thanks!

Viewing all articles
Browse latest Browse all 50085

Trending Articles