VBA Function returns "#VALUE"

hfler

Board Regular
Joined
Jun 10, 2008
Messages
95
Any ideas why this function returns #VALUE? It's try to return the vega greek for black scholes. All variables are public constants.

Code:
Function OptionVega(strike, spotprice, time, vol) As Double
volrootime = (time ^ 0.5) * vol
        
topline1 = Log(spotprice / strike)
topline2 = ((vol ^ 2) / 2) * time
topline = topline1 + topline2
d1 = topline / volrootime
If ((strike <= 0) Or (time = 0)) Then
OptionVega = 0
Else
OptionVega = Application.Exp(-0.5 * d1 * d1) * strike * Application.Sqrt((0.25 * time) / (Pi / 2))
 
End If
End Function

Thanks for any advice!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I haven't tested your function, but try it with WorksheetFunction.Pi.

I strongly recommend that you put Option Explicit at the top of your module. Then you will get a compile error if there are any undeclared variables.
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,685
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top