I assume you are referring to Binomial Tree model.
Here is the customized function code.
-------------------------------------------------------------------------------
Binomial Tree Excel VBA Code
-------------------------------------------------------------------------------
Function binomial_tree(S, K, t, r, sigma, N)
Dim delta_t As Double
Dim u As Double
Dim d As Double
Dim j As Integer 'number of up movements on the tree
Dim i As Integer 'number of time intervals that have passed
Dim a As Double
Dim call_price() As Double
Dim put_price() As Double
Dim p As Double
delta_t = t / N
u = Exp(sigma * Sqr(delta_t))
d = -Exp(sigma * Sqr(delta_t))
a = Exp(r * delta_t)
p = (a - d) / (u - d)
ReDim call_price(1 To N, 1 To N)
ReDim put_price(1 To N, 1 To N)
For j = N To 1 Step -1
call_price(N, j) = WorksheetFunction.Max(S * u ^ j * d ^ (N - j) - K, 0)
put_price(N, j) = WorksheetFunction.Max(K - S * u ^ j * d ^ (N - j), 0)
For i = N - 1 To 1 Step -1
For j = N - 1 To 1 Step -1
call_price(i, j) = Exp(-r * delta_t) * (p * call_price(i + 1, j + 1) + (1 - p) *
call_price(i + 1, j))
put_price(i, j) = Exp(-r * delta_t) * (p * put_price(i + 1, j + 1) + (1 - p) *
put_price(i + 1, j))
Next j
Next i
binomial_tree = Array(call_price, put_price)
End Function
=======================================================
Copy the code in your Excel developer VBA interface.
It should solve your problem.
Good luck.