# VBA, Bisection & Yield To Maturity

#### Unicorn_Bazooka

##### New Member
Given
YTM- between 0 and 1
C are coupon rates, for example 7, 7, 9
P are the dirty price, for example 101, 148, 192
R = positive integer values
S= positive integer values
N= positive integer values between 0 and 20
E=1 (always for each row of data)
Function==>f(YTM, c, P, r, s,n,e) = d^(r/s)*((e*(c/2)+(c/2)*(d-d^(n+1))/(1-d)+100*d^n)-P
where d= 1/(1+ytm/2)

how would I implement a bisection function which will check for values between 0.000001 and 1 to solve for YTM (obviously when the above function = 0) ?

I understand YTM is going to an interest rate of sort so it has to be between 0 and 1 strictly positive for this function.

Also how would I make a command button (on click it will compute the bisection for many rows of variables)?

### Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Replies
6
Views
345
Replies
4
Views
251
Replies
21
Views
510
Replies
20
Views
503
Replies
2
Views
476

1,191,633
Messages
5,987,783
Members
440,110
Latest member
albertod8

### 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?

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