HELP my function is acting weird

chenyu768

New Member
Joined
May 25, 2011
Messages
21
HELP! This function doesn't always work. sometimes it'll calculate sometimes it won't. I checked auto calculate and i pressed F9. It seems to work sometimes when i retype the formula but considering i have 24months x 2000 clients it can get a little much.

Can someone please help audit this for me!

Code:
Function Delta_Call(pipe, date_val, nymex_vol, usage, exp_date, asof_date, call_prc, k_type, Fixed)

If k_type = "PARTNER" Then
call_prc = Fixed
Else
call_prc = call_prc
End If

index_val = WorksheetFunction.Index(Range("monthly_index"), WorksheetFunction.Match(pipe, Range("indexes_names"), 0), WorksheetFunction.Match(date_val, Range("Index_date"), 0))

tT = (exp_date - asof_date + 1) / 365
p1 = (Log(index_val / call_prc)) + (nymex_vol ^ 2 / 2 * (tT))
p2 = (nymex_vol * tT ^ (1 / 2))
d1 = p1 / p2


CallDelta = (WorksheetFunction.NormSDist(d1) * Exp(-0.025 * tT))
Delta_Call = CallDelta * usage


End Function
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Try this

Rich (BB code):
Function Delta_Call(pipe, date_val, nymex_vol, usage, exp_date, asof_date, call_prc, k_type, Fixed)
Application.Volatile
If k_type = "PARTNER" Then
 
Upvote 0
Holy mole, You sir are a gentleman and a scholar. This totally worked. Thank you so much, you just saved my life!
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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