ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help With Vba Code (https://www.excelbanter.com/excel-programming/366665-help-vba-code.html)

Suz84

Help With Vba Code
 

Dear All,

I am new to VBA and am stuck on trying to find the mean of a range of
values outputted by the following code:

' Create storage for FTSE100 and binary payoff simulations.
ReDim IndexSim(1 To SampleSz) As Double
ReDim Payoff(1 To SampleSz) As Double

'Do the simulations.
For Cnt = 1 To SampleSz
IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow)

If IndexSim(Cnt) = IndexBetValue Then
Payoff(Cnt) = Range("D18").Value
Else
Payoff(Cnt) = Range("D19").Value
End If



Next Cnt

The first and last parts of the code have been omitted, but please
could somebody help me to attempt to find the mean of the IndexSim and
Payoff values outputted by the function.

Many thanks,

Suz


--
Suz84
------------------------------------------------------------------------
Suz84's Profile: http://www.excelforum.com/member.php...o&userid=36189
View this thread: http://www.excelforum.com/showthread...hreadid=559616


Tom Ogilvy

Help With Vba Code
 



For Cnt = 1 To SampleSz
IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow)

If IndexSim(Cnt) = IndexBetValue Then
Payoff(Cnt) = Range("D18").Value
Else
Payoff(Cnt) = Range("D19").Value
End If
Next Cnt


meanIndex = Application.Average(IndexSim)
meanPayoff = Application.Average(Payoff)

--
Regards,
Tom Ogilvy


"Suz84" wrote in
message ...

Dear All,

I am new to VBA and am stuck on trying to find the mean of a range of
values outputted by the following code:

' Create storage for FTSE100 and binary payoff simulations.
ReDim IndexSim(1 To SampleSz) As Double
ReDim Payoff(1 To SampleSz) As Double

'Do the simulations.
For Cnt = 1 To SampleSz
IndexSim(Cnt) = gBmProcess(Kt, r, q, Vol, TMat - TNow)

If IndexSim(Cnt) = IndexBetValue Then
Payoff(Cnt) = Range("D18").Value
Else
Payoff(Cnt) = Range("D19").Value
End If



Next Cnt

The first and last parts of the code have been omitted, but please
could somebody help me to attempt to find the mean of the IndexSim and
Payoff values outputted by the function.

Many thanks,

Suz


--
Suz84
------------------------------------------------------------------------
Suz84's Profile:
http://www.excelforum.com/member.php...o&userid=36189
View this thread: http://www.excelforum.com/showthread...hreadid=559616





All times are GMT +1. The time now is 07:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com