Interest rate cap/floors with excel-help me plz

gstackle32's picture
Rank: Gorilla | 608

For all you excel monkeys out there I could use some help.

I'm currently trying to create a function that checks if a given interest rate is within both an annual (change from last year) and lifetime cap.

Annual cap is 1% lifetime cap is 5% (beginning interest rate is 6.75%).

I tried an IF statemetn and that turned into a black hole. Also messed around with a MAX and MIN function to no avail...

Ideas?

Comments (8)

May 14, 2012

Trying using the VLOOKUP function.

May 14, 2012

You can also use a custom function...pull up VBA (alt+f11), insert a new module into your worksheet, and paste this in

Function IntCapTest(IntBegin As Double, IntPrior As Double, IntCurrent As Double) As Boolean

'Created by Nabooru
'
'This is a custom funtion used to check if a given interest
'rate is within both an annual and lifetime cap. The function
'uses 3 inputs: the beginning interest rate, the prior
'period interest rate, and the current interest rate.

Dim AnnCap As Double
Dim LifeCap As Double

'Declare max variations

AnnCap = 0.01
LifeCap = 0.05

Dim AnnCapTest As Double
Dim LifeCapTest As Double

'Determine actual veriation (abs. value variation)

AnnCapTest = Abs((IntCurrent - IntPrior) / IntPrior)
LifeCapTest = Abs((IntCurrent - IntBegin) / IntBegin)

'Test whether abs. value of variation is within the declared
'Cap and return true/false accordingly

If AnnCapTest < AnnCap And LifeCapTest < LifeCap Then IntCapTest = True
If AnnCapTest >= AnnCap Or LifeCapTest >= LifeCap Then IntCapTest = False

End Function

    • 1
May 14, 2012
Nabooru:

You can also use a custom function...pull up VBA (alt+f11), insert a new module into your worksheet, and paste this in

Function IntCapTest(IntBegin As Double, IntPrior As Double, IntCurrent As Double) As Boolean

'Created by Nabooru
'
'This is a custom funtion used to check if a given interest
'rate is within both an annual and lifetime cap. The function
'uses 3 inputs: the beginning interest rate, the prior
'period interest rate, and the current interest rate.

Dim AnnCap As Double
Dim LifeCap As Double

'Declare max variations

AnnCap = 0.01
LifeCap = 0.05

Dim AnnCapTest As Double
Dim LifeCapTest As Double

'Determine actual veriation (abs. value variation)

AnnCapTest = Abs((IntCurrent - IntPrior) / IntPrior)
LifeCapTest = Abs((IntCurrent - IntBegin) / IntBegin)

'Test whether abs. value of variation is within the declared
'Cap and return true/false accordingly

If AnnCapTest < AnnCap And LifeCapTest < LifeCap Then IntCapTest = True
If AnnCapTest >= AnnCap Or LifeCapTest >= LifeCap Then IntCapTest = False

End Function

Thanks a ton man!

I inserted this into a new module, how do I go about applying this to my finally payrate cell each year? Also, I should have mentioned the function needs to return the what the interest rate for the current year will be taking into account the caps and floors. Sorry for the dumb questions and thanks again for writing that.

May 14, 2012

sorry it's a bit hard to visualize this w/o seeing the spreadsheet but once you put the code into the module you can go into the worksheet and use it like a normal function, i.e. type in =IntCapTest([beginning interest rate here],[prior year interest rate here],[current rate here]) as if you were using a normal built-in Excel formula. hope that helps; otherwise I should show you from a sample

May 14, 2012
Nabooru:

sorry it's a bit hard to visualize this w/o seeing the spreadsheet but once you put the code into the module you can go into the worksheet and use it like a normal function, i.e. type in =IntCapTest([beginning interest rate here],[prior year interest rate here],[current rate here]) as if you were using a normal built-in Excel formula. hope that helps; otherwise I should show you from a sample

got it, thanks.

Any insight on how I would go about altering this to return what the interest rate for the year needs to be given the cap and floor limitations?

May 14, 2012

well I think that would be a range so do you mean the max variance you could have for the year or the actual max/min result you could have based on that variance?

May 14, 2012

Yes, for the lifetime cap I think it would be a variance, e.g. between 1.75% and 11.75%.

Maybe this will help. Here's what I'm looking at in excel

A1: Index rate(fluctuates) + A2: 1.25(margin) = A3:Contract Interest rate(annual & lifetime caps need to be applied here).

EX:

4.00% + 1.25% = 5.25%; last period IR was 6.75%, therefore cell A3 needs to return 5.75% (1% annual cap)

that help?

May 14, 2012
Comment