How to Calculate Interest Using the Last Populated Row in Excel
Question details
The user wants to dynamically calculate loan interest using the date and amount from the last populated row in their spreadsheet instead of relying on hard-coded cell references.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Managing a loan spreadsheet and calculating interest dynamically based on the most recent payment entry.
- Observed behavior
- The current formula relies on fixed cell references, requiring manual updates every time a new payment is added to a new row.
Ensure your payment dates are formatted correctly as Dates, and amounts are formatted as Numbers, to allow formula functions like LOOKUP and DATEDIF to calculate accurately.
Use the LOOKUP Function to Handle Data with Blanks
The LOOKUP function combined with a massive number is the most robust way to find the last numeric value in a column, ensuring accurate references even if there are empty cells in between.
By searching for an extremely large number (like 1E100) that is guaranteed not to exist in your dataset, the LOOKUP function automatically defaults to the last numeric value present in the specified range.
Click on the cell where you want to display the calculated interest.
Enter the following formula: =LOOKUP(1E100,B2:B100)*(DATEDIF(LOOKUP(1E100,A2:A100),H2,"d")/360)*0.05. Modify the ranges based on your sheet: A2:A100 for dates, B2:B100 for amounts, and H2 for the current date.
Press Enter to execute the formula. It will automatically fetch the last populated values in columns A and B to calculate the interest.

Use INDEX and COUNTA for Continuous Data Without Blanks
If your data is perfectly continuous without any empty rows, combining INDEX and COUNTA provides a clean way to reference the last row.
Automate Loan Spreadsheets with WPS Spreadsheet
WPS Spreadsheet fully supports advanced array formulas, LOOKUP, and INDEX functions, allowing you to easily build automated, dynamic financial trackers without manually updating cell references.
- 1. Open your loan document: Launch WPS Spreadsheet and open your loan tracking .xlsx file.
- 2. Select the interest cell: Click on the target cell where the interest calculation should appear.
- 3. Enter the dynamic formula: Input your dynamic LOOKUP or INDEX formula to securely reference the last populated rows.
- 4. Save your work: Press Enter to instantly calculate the interest, and save your document to keep your fully automated setup.

Frequently Asked Questions
Why does my DATEDIF function return a #NUM! error?
The DATEDIF function returns a #NUM! error if the start date is later than the end date. Ensure the date pulled from your last populated row is chronologically before the current calculation date, and verify that both cells contain valid Date formats, not text.
Can I use XLOOKUP to find the last populated row instead?
Yes, in modern spreadsheet software like newer versions of Excel or WPS Office, you can use XLOOKUP. By setting the search mode to -1, it searches from the last item to the first. For example: =XLOOKUP(TRUE, A:A<>"", A:A, "", 0, -1).
How does the INDEX and COUNTA method handle table headers?
If your column has a text header, the COUNTA function will include it in the total count of non-empty cells. You must subtract the number of header rows from the COUNTA result to get the correct row index. For example, if you have one header row, use =INDEX(A:A, COUNTA(A:A)-1).




