Library › Coding AI › Finance and accounting
Build a running balance where debits mean money out
Practice: Giving the right context. About 5 minutes.
About this exercise
Write one formula for Ledger!F2 that you can fill down unchanged, giving the running balance after each line. Start from the opening balance in $H$1. This export is from the bank's side, so Debit (column D) is money out and Credit (column E) is money in. Use expanding ranges anchored at row 2, so row 2 needs no special formula. One formula in one code block, then under 25 words outside the code.
Common mistakes when you ask AI for this
- Not saying whose side it is. The AI uses the accounting meaning and adds debits, so the balance runs the wrong way. Try: Add: "Bank's side: Debit is money out, Credit is money in."
- Not giving the opening balance. The AI starts at zero or points at the header row above. Try: Add: "Start from the opening balance in $H$1."
- Leaving the first row awkward. The AI writes F1+D2-E2, which breaks on row 2 because F1 is a header. Try: Add: "Expanding ranges from row 2, so one formula fills down."
- Getting a menu of options. The AI likes to offer two or three versions of the formula, so you're left to pick and test them yourself. Try: Add: "Give one formula only, in one code block, no alternatives."
- Getting a tutorial. By default the AI explains every part of the code at length, which you then have to scroll past. Try: Add: "After the code, one line under 10 words. Nothing else."
What a strong prompt includes
- Says debit is money out
- Gives the opening balance
- Asks for one fill-down formula
- Asks for one answer only
- Limits the explanation
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)