Sub topic 10
Debt Repayment Limited by Cash and Balance
This chapter builds the cash sweep, a formula that repays debt from available cash. It assumes you can anchor references, copy formulas across a row of periods, and read a simple forecast layout. It also assumes you know the MIN and MAX behavior from earlier chapters and the terms opening balance, closing balance, and free cash flow.
Why repayment needs limits
A debt schedule decides how much principal the company repays each period. A simple version repays a fixed amount. A sweep repays whatever cash is available, up to the amount owed.
Two limits keep the result sensible:
- The company cannot repay more than it owes. Otherwise the debt balance goes negative, which would mean the lender owes the company money.
- The company cannot repay with cash it does not have. If cash available is negative, the model should repay nothing. It should not "borrow" by making the repayment negative.
Both limits are one-sided. Repayment has a ceiling (the balance) and a floor (zero). Those are the cap and floor tools from the previous chapters, combined in a single formula.
The core formula
Assume these rows in the model:
| Row | Item | Meaning |
|---|---|---|
| 38 | Cash available for repayment | Cash generated plus opening cash, less the minimum cash the company must keep |
| 41 | Opening debt balance | Debt outstanding at the start of the period |
| 42 | Repayment | The formula we are building |
| 43 | Closing debt balance | Opening balance less repayment |
The repayment formula in row 42 is:
=MIN(F41,MAX(0,F38))Read it from the inside out:
MAX(0,F38)applies a floor of zero. If cash available is negative, the result is 0. If it is positive, the result is that amount.MIN(F41, ...)applies a cap at the opening balance. The result is whichever is smaller: the debt owed or the cash available.
The closing balance is then:
=F41-F42Because repayment never exceeds the opening balance, the closing balance never falls below zero.
Worked example
The table shows four periods with the same opening balance logic. The closing balance of each period becomes the opening balance of the next.
| Period | Opening debt | Cash available | MAX(0, cash) | Repayment | Closing debt |
|---|---|---|---|---|---|
| 1 | 100 | 40 | 40 | 40 | 60 |
| 2 | 60 | -15 | 0 | 0 | 60 |
| 3 | 60 | 35 | 35 | 35 | 25 |
| 4 | 25 | 50 | 50 | 25 | 0 |
Period 2 shows the floor at work: negative cash produces no repayment, and the debt stays at 60. Period 4 shows the cap: 50 of cash is available, but only 25 is owed, so the repayment is 25.
Where "cash available" comes from
The formula is only as good as row 38. A common definition is:
Cash available for repayment =
Opening cash
+ Cash flow before debt repayment
- Minimum cash balanceEach part matters:
- Opening cash is the prior period's closing cash.
- Cash flow before debt repayment includes operating cash flow and investing cash flow, plus any interest and tax already calculated. It excludes the repayment itself.
- Minimum cash balance is an input. It reflects cash the business needs to operate. Without it, the sweep would drain cash to zero.
Keep the minimum cash balance in an input cell, for example $C$6, and refer to it with an anchored reference. Do not type the number into the formula.
Avoiding a circular reference
Interest links the debt schedule back to cash. If interest is calculated on the closing or average debt balance, then interest affects cash flow, cash flow affects repayment, and repayment affects the closing balance. That loop is a circular reference, and Excel will warn about it or give unstable results unless iterative calculation is turned on.
The simplest way to avoid the loop is to calculate interest on the opening balance:
=F41*$C$7Here C7 is the interest rate input. The opening balance is already known at the start of the period, so it does not depend on this period's repayment. This is less precise than an average balance, but it is stable and easy to audit.
If you need average-balance interest, that is a deliberate modeling choice. It requires iterative calculation or a circuit breaker switch. A circuit breaker is a 1/0 switch that sets interest to zero when the loop breaks. It is outside this chapter's scope.
Adding a repayment switch
You may want to turn the sweep on or off, for example to compare scenarios. A switch cell holds 1 (sweep on) or 0 (sweep off). Suppose C8 holds it. Multiply the repayment by the switch:
=MIN(F41,MAX(0,F38))*$C$8With C8 at 0, the repayment is 0 and the debt balance stays flat (apart from any scheduled repayments you add separately). With C8 at 1, the sweep works as before.
Use multiplication rather than an IF here. The switch is a pure on/off gate, so multiplication keeps the formula short and still readable.
Mandatory and optional repayment
Many loans have a scheduled repayment that must be paid whether or not cash is plentiful, plus an optional sweep on top. Split the two so each can be audited.
Assume row 44 holds the scheduled repayment from the loan agreement:
=MIN(F41,F44)This caps the scheduled amount at the balance, so the final payment is smaller if less is owed. Then calculate the optional sweep using the balance remaining after the scheduled payment and the cash remaining after it:
=MIN(F41-F45,MAX(0,F38-F45))*$C$8Here F45 is the scheduled repayment result. The sweep cannot exceed what is still owed (F41-F45) and cannot use cash already spent on the scheduled payment (F38-F45). Total repayment is the sum of the two rows.
If cash available is smaller than the scheduled repayment, the sweep becomes zero through the floor. The scheduled payment itself still shows in full. That is intentional, because the loan agreement requires it, but it can push cash below the minimum or below zero. Add a check row that flags this (see the next section).
Checks that catch mistakes
Add check rows beneath the schedule. Each returns 1 for a problem and 0 for none, so you can sum them into a single warning cell.
=IF(F43<0,1,0)This flags a negative closing debt balance, which the cap should prevent.
=IF(F46<0,1,0)Here F46 is closing cash. This flags a cash shortfall, which can happen when scheduled repayments exceed available cash.
A third useful check compares total repayment against the two limits. It confirms that the repayment never exceeds either.
=IF(OR(F42>F41,F42<0),1,0)Summing the check rows into a master check, and showing it near the top of the model, makes errors visible without inspecting every column.
Common errors
- Using only MIN.
=MIN(F41,F38)caps repayment at the balance but allows a negative repayment when cash is negative. A negative repayment increases the debt, which may look like a hidden borrowing. - Using only MAX.
=MAX(0,F38)floors repayment at zero but lets it exceed the balance, so debt goes negative. - Swapped functions.
=MAX(F41,MIN(0,F38))returns the wrong values. Remember that MIN creates a ceiling and MAX creates a floor. - Pointing at the closing balance. If the cap refers to the closing balance, which depends on the repayment, the formula is circular. Use the opening balance.
- Forgetting the minimum cash. Without it, the sweep can take every unit of cash and leave the model with no operating buffer.
- Hard-coded switch or rate values. Typing
1or0.05in a formula hides assumptions. Reference input cells. - Inconsistent formulas across the row. A different formula in one column, such as a manual override, breaks the pattern. Use one formula across the whole timeline.
A flow of the calculation
The diagram shows the order in which the numbers feed each other in one period.
Testing the formula
Test the extremes before you trust the schedule. Change the inputs and confirm the results:
- Set the opening debt to 0. Repayment should be 0.
- Set cash flow very negative. Repayment should be 0 and debt unchanged.
- Set cash flow very large. Repayment should equal the opening balance and closing debt should be 0.
- Set the sweep switch to 0. Repayment should be 0.
- Raise the minimum cash balance above the cash on hand. Repayment should be 0.
Checking the edges is faster than reading formulas, and it catches the cases that matter most.
Summary of the pattern
- Floor the cash at zero with
MAX(0, cash). - Cap the result at the opening balance with
MIN(balance, ...). - Gate the result with a 1/0 switch by multiplication if you need on/off control.
- Calculate interest on the opening balance to avoid circularity.
- Add check rows that return 1 when a rule is broken.
Exercise
Opening debt is 80, cash available is 120, and the sweep switch is 1. A scheduled repayment of 20 is paid first. Using the scheduled-plus-sweep approach, what are the scheduled repayment, the sweep, and the closing debt?
Show answer
Scheduled repayment = MIN(80, 20) = 20. Sweep = MIN(80-20, MAX(0, 120-20)) * 1 = MIN(60, 100) = 60. Total repayment = 80, so closing debt = 80 - 80 = 0. The sweep is limited by the remaining balance, not by the available cash.
Exercise
A colleague writes the repayment formula as =MIN(F41,F38). Cash available in F38 is -30 and the opening balance in F41 is 90. What does it return, what is the effect on the debt balance, and how do you fix it?
Show answer
It returns -30, because -30 is smaller than 90. The closing balance becomes 90 - (-30) = 120, so the debt rises as if the company borrowed. Fix it by flooring cash at zero: =MIN(F41,MAX(0,F38)), which returns 0 and leaves the debt at 90.
Exercise
Write a check formula that returns 1 when the sweep switch in C8 is anything other than 0 or 1, and 0 otherwise.
Show answer
=IF(OR($C$8=0,$C$8=1),0,1). It returns 0 for a valid switch and 1 for any other value, such as 2 or a blank-like text entry.