-
Solved: User defined function not appearing
Hello everyone,
I just typed a function on VBE but it is not appearing on my functions is it normal?
Here is the code Function getcallprice(spot_, strike_, maturity_, pricing_date_, divyield, rate_, vol_)
If IsEmpty(vol_) Or vol_ = 0 Then vol_ = 0.25
maturity_ = maturity_ - pricing_date_
If maturity_ < 0 Then
getcallprice = 0
Exit Function
End If
maturity_ = Application.Max(maturity_ / 365, 1 / 365)
d1 = 1 / (vol_ * Sqr(maturity_)) * (Log(spot_ / strike_) + (rate_ - divyield_ + 1 / 2 * vol_ ^ 2) * maturity_)
d2 = d1 - vol_ * Sqr(maturity_)
Nd1 = Application.NormSDist(d1)
Nd2 = Application.NormSDist(d2)
getcallprice = Nd1 * spot_ * Exp(-divyield_ * maturity_) - Nd2 * strike_ * Exp(-rate_ * maturity)
End Function
Thanks a lot!
REgards
-
Did you put it in a Module and looked in User Defined Functions category?
You can add descriptive text by Application.MacroOptions.
I recommend using
[VBA]Option Explicit[/VBA]
as first line of code in a Module.
Please use VBA code tags for pasted code.
-
Thanks a lot Kenneth sorry for that
Do you know if there is an option for "unexplicit"?
Because in this case I don't want to specify
Regards thanks again
-
Just don't add that line if you don't want to bother using Dim or setting variable types as Off is the default.
I can only recommend, it is up to you to decide whether you take my advice or not. Some others feel the same:
http://www.cpearson.com/excel/declaringvariables.aspx
http://effectivemsofficesolutions.co...Practices.html
http://www.fmsinc.com/free/NewTips/V...ion/index.html
http://www.fincad.com/pdfs/vba_coding.pdf
Setting Option Explicit Off and On:
http://msdn.microsoft.com/en-us/library/y9341s4f.aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules