# Iteration in Excel

Iteration in Excel is used when a formula depends on the result of its own calculation from a previous iteration. This means that the formula must be recalculated multiple times until the result stops changing significantly.

One common use case for iteration in Excel is when creating financial models or forecasting models that involve iterative calculations, such as calculating interest on a loan or estimating future sales growth based on historical data.

For example, if you have a formula that calculates the interest payment on a loan based on the current outstanding balance, and the interest payment affects the outstanding balance, then you would need to use iteration to ensure that the formula produces an accurate result.

To set up iteration in Excel, you need to specify the maximum number of iterations to perform and the amount by which the result should change before the calculation stops.

## Enabling Excel Iterative Calculations

Excel’s iterative calculations feature allows you to repeatedly calculate a worksheet until a specific condition is met.

This can be useful in situations where a calculation formula requires multiple iterations to converge on a solution, such as in financial modeling or engineering simulations.

To enable iterative calculations in Excel, follow these steps:

1. Click on the “File” menu and select “Options“.
2. In the Excel Options dialog box, select “Formulas” from the left-hand menu.
3. Check the box next to “Enable iterative calculation“.
4. Specify the maximum number of iterations and the desired level of precision in the corresponding fields.
5. Click “OK” to save your changes and exit the dialog box.

Once iterative calculations are enabled, you can enter a formula that depends on the result of its own calculation into a cell, and Excel will automatically recalculate the formula until it reaches a stable result within the specified number of iterations and precision level.

## Examples of iteration in excel

Let’s say you have a loan of \$10,000 with an annual interest rate of 5%, compounded monthly. The loan is to be repaid over a period of 12 months in equal monthly installments.

To calculate the monthly installment amount, you would use the following formula:

Monthly Installment = (P * r * (1 + r)^n) / ((1 + r)^n – 1)

Where: P = Loan principal (\$10,000) r = Monthly interest rate (5% / 12) n = Total number of payments (12)

Using this formula, the monthly installment amount comes out to be \$859.35 per month.

However, each monthly payment also includes an interest component, which reduces the outstanding balance of the loan. So, to calculate the interest payment for the second month, you would need to use the following formula:

Interest Payment = Outstanding Balance * Monthly Interest Rate

Where: Outstanding Balance = Original loan principal – Principal paid in first month Monthly Interest Rate = Annual interest rate / 12

To calculate the principal paid in the first month, you would subtract the interest payment from the first month’s installment:

Principal Paid in Month 1 = Monthly Installment – Interest Payment for Month 1

Using these formulas, you can calculate the interest payment and principal paid for each month, and then use iteration to update the outstanding balance for each subsequent month until the loan is fully paid off.

This ensures that the interest payment accurately reflects the changing outstanding balance of the loan.

1. Open a new Excel spreadsheet and enter the following values in cells A1 to A3
• :A1: Loan principal
• A2: Annual interest rate
• A3: Number of payments
2. Enter the corresponding values for each of these parameters in cells B1 to B3:
• B1: \$10,000 (or the loan amount you want to calculate)
• B2: 5% (or the annual interest rate)
• B3: 12 (or the number of payments)
3. Calculate the monthly interest rate by dividing the annual interest rate by 12. Enter the following formula in cell B4:
• B4: =B2/12
• This will give you the monthly interest rate.
4. Calculate the monthly installment amount by using the formula in cell B5:
• B5: =(B1*B4*(1+B4)^B3)/((1+B4)^B3-1)
• This will give you the monthly installment amount, which is \$859.35.
5. Calculate the outstanding balance after the first payment by subtracting the first month’s principal from the loan amount. Enter the following formula in cell B6:
• B6: =B1-B5
• This will give you the outstanding balance after the first payment.
6. Calculate the interest payment for the second month by multiplying the outstanding balance after the first payment by the monthly interest rate. Enter the following formula in cell B7:
• B7: =B6*B4
• This will give you the interest payment for the second month.
7. Calculate the principal paid in the second month by subtracting the interest payment for the second month from the monthly installment amount. Enter the following formula in cell B8:
• B8: =B5-B7
• This will give you the principal paid in the second month.
8. Calculate the outstanding balance after the second payment by subtracting the principal paid in the second month from the outstanding balance after the first payment. Enter the following formula in cell B9:
• B9: =B6-B8
• This will give you the outstanding balance after the second payment.

Copy the formulas in cells B1 to B6 and paste them into cells F1 to F6 for the third month’s interest payment, principal paid, and outstanding balance.

That’s it! You now have a table that shows how the loan is repaid over time with each monthly installment.

## Automatically insert time stamp when an order is marked

you have a table of orders in an Excel sheet with the order date and the date the order was processed. You want to use the formula you provided to automatically insert the current time stamp in the “Processed Date” column when an order is marked as processed.

Here are the steps:

1. Open your Excel sheet and select the column where you want to add the time stamp (in this example, it’s column I for “Processed Date”).
2. In the first cell of the column (B2), enter the following formula:

=IF(A2<>””,IF(B2<>””,B2,NOW()),””)

This formula checks if there is a value in the corresponding cell in column A (which would indicate that an order has been placed).

If there is, it checks if there is already a value in the current cell in column B (which would mean the order has already been processed). If there isn’t, it inserts the current time stamp using the NOW() function. If there is already a value, it leaves it unchanged.

If there is no value in column A, it leaves the cell in column B blank.

1. Copy this formula down the entire column (e.g. by double-clicking the bottom right corner of the cell you just entered the formula in).

Now, whenever you enter a new order in column A and mark it as processed by adding a value in column B, the corresponding cell in column I will automatically be filled with the current timestamp.