Compile error: expected end of statement

Kotepie

Board Regular
Joined
Sep 1, 2010
Messages
55
Hello-I'm trying to write a code for calculating the value of an option. I keep getting a compile error with the i highlighted and can't figure out why for the life of me. I bolded where it highlights the error. Any help would be greatly appreciated. Thank you

Function BinomEuro(S, K, T, rf, sigma, n, TypeOpt As String)
dt = T / n
u = Exp(sigma * dt^(0.5))
d = 1 / u
p = (Exp(rf * dt) - d) / (u - d)

BinomEuro = 0
For i = 0 To n
Select Case TypeOpt
Case "call":
BinomEuro = BinomEuro + Application.Combin(n, i)*p^i*(1-p)^(n-1)*Application.MaxChange(0,S*u^i*d^(n-1)-K)
Case "Put":
BinomEuro = BinomEuro + Application.Combin(n, i)* p^i*(1-p)^(n-1)*Application.MaxChange(0,K-S*u^i*d^(n-1))
End Select



Next i

BinomEuro = Exp(-rf * T) * BinomEuro
End Function
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Missing a few spaces, the compiler is getting narky :oops:
VBA Code:
Function BinomEuro(S, K, T, rf, sigma, n, TypeOpt As String)
    dt = T / n
    u = Exp(sigma * dt^(0.5))
    d = 1 / u
    p = (Exp(rf * dt) - d) / (u - d)
    BinomEuro = 0
For i = 0 To n
    Select Case TypeOpt
        Case "call":
            BinomEuro = BinomEuro + Application.Combin(n, i) * p ^ i * (1 - p) ^ (n - 1) * Application.MaxChange(0, S * u ^ i * d ^ (n - 1) - K)
        Case "Put":
            BinomEuro = BinomEuro + Application.Combin(n, i) * p ^ i * (1 - p) ^ (n - 1) * Application.MaxChange(0, K - S * u ^ i * d ^ (n - 1))
    End Select
Next i
    BinomEuro = Exp(-rf * T) * BinomEuro
End Function
 
Upvote 0
Thank you so much. I've spent hours on this trying to figure out what I was doing wrong. Thanks once again.
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,393
Members
449,081
Latest member
JAMES KECULAH

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