Binomial tree

AldoGCS

New Member
Joined
Apr 26, 2018
Messages
1
Hello i need a code that can make a Binomial Tree with some black spaces in between each probability
Code:
Sub Create(Pasos As Long, RangoSalida As Range, Volatilidad As Variant, TVencimiento As Variant, RF As Variant, Dividendos As Variant)

Dim M() As Variant
Dim i As Long, j As Long
ReDim M((2 * (Pasos ^ 2) + 3), Pasos)
    U = Exp(Volatilidad * (TVencimiento / Pasos) ^ (1 / 2))
    
    D = 1 / U
    a = Exp((RF - Dividendos) * (TVencimiento / Pasos))
    P = (a - D) / (U - D)
    Q = 1 - P


M(Pasos + 1, 0) = 50

For j = 1 To Pasos
For i = 1 To 2 * Pasos + 1
    If M(i + 1, j - 1) <> "" And M(i - 1, j - 1) <> "" Then
        
        M(i, j) = M(i - 1, j - 1) * D
        
    ElseIf M(i + 1, j - 1) <> "" Then
         M(i, j) = M(i + 1, j - 1) * U
    ElseIf M(i - 1, j - 1) <> "" Then
            M(i, j) = M(i - 1, j - 1) * D
            
       End If
       Next i
[LEFT][COLOR=#222222][FONT=Verdana]
[/FONT][/COLOR][/LEFT]

59.4555
56.12005
52.9717152.97171
5050
47.19547.195
44.54736
42.04826

<colgroup><col width="64" style="width:48pt" span="4"> </colgroup><tbody>
</tbody>
this is a example of what that code do

and this is what i need

59.4555
56.12005
52.9717152.97171
5050
47.19547.195
44.54736
42.04826

<colgroup><col width="64" style="width:48pt" span="4"> </colgroup><tbody>
</tbody>
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi

You did not post all the code.

Anyway, a simple solution is to add a loop to insert 1 (or more) rows between the rows of your present solution.
 
Upvote 0

Forum statistics

Threads
1,213,567
Messages
6,114,342
Members
448,570
Latest member
rik81h

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