debug -

L

laguo

I am new to VBA..i wrote the following code..it basically take 5
variables and use as imputs for a a formula.
i won't work for me..can someone help see what is wrong. Thanks for
your help!

Option Explicit

Private Sub CommandButton1_Click()

Dim Spot As Double
Dim strike As Double
Dim RF As Double
Dim Vol As Double
Dim YTM As Double

Dim Call_PX As Variant
Dim d1 As Variant
Dim d2 As Variant
Dim CallPx As Variant

On Error GoTo EndMacro

Spot = ActiveCell.Range("B12").Value
strike = ActiveCell.Range("B13").Value
RF = ActiveCell.Range("B14").Value
YTM = ActiveCell.Range("B15").Value
Vol = ActiveCell.Range("B16").Value

d1 = (Log(Spot / strike) + (RF + (0.5 * Vol ^ 2)) * YTM) / (Vol * YTM
^ 0.5)
d2 = d1 - Vol * YTM ^ 0.5
CallPx = Spot * WorksheetFunction.NormSDist(d1) - strike * Exp(-RF *
YTM) * WorksheetFunction.NormSDist(d2)
Range("B18").Value = CallPx
EndMacro:
End Sub
 

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