Google Sheets Guide · Prompt: “Compute a cumulative running total for Net Amount in column B across rows 2 to 6”
Auto-Expanding Running Balance in Google Sheets (SCAN + LAMBDA)
Verified by LiveFormulaLab Engineering Team • Updated November 2026
Create an automatic running balance column in Google Sheets with SCAN and LAMBDA or SUMIF ROW. Never drag formulas again.
Verified Google Sheets Syntax
=SUM($B$2:B2)How This Formula Works (Step-by-Step)
Using SCAN(0, B2:B, LAMBDA(acc, val, acc + val)) computes a cumulative running balance across an entire open-ended Google Sheets column in one single formula.
Step 1: Start the accumulator at 0.
Step 2: For each row value, add it to the previous accumulator so new rows calculate automatically.
Formula Syntax & Arguments Breakdown
Computes cumulative cash or account balances across ordered rows using locked-top SUM($B$2:B2) or modern single-cell SCAN(0, B2:B6, LAMBDA(...)) array evaluation.
| Argument / Clause | Requirement | Data Type | Role & Behavior |
|---|---|---|---|
start_ref ($B$2) | Required | Absolute Reference | Fixed opening transaction cell anchored with $ signs so cumulative summing always starts at row 2. |
current_ref (B2) | Required | Relative Reference | Current row amount included in the running sum up through this line. |
3 Real-World Use Cases
- Maintaining live checking account balances from CSV bank imports.
- Tracking cumulative burn rate across monthly expense logs.
- Auto-updating inventory stock levels after receipts and shipments.
Cross-Platform Equivalents
- Excel
=SCAN(0, B2:B6, LAMBDA(acc, v, acc+v))- SQL
SELECT entry_date, net_cash_flow, SUM(net_cash_flow) OVER (ORDER BY entry_date) AS running_balance FROM ledger;- Python Pandas
df['Running Balance'] = df['Net Cash Flow'].cumsum()
Common Mistakes & Pro Tips
Pitfalls & How to Fix Them
Mistake: Standard SUM($B$2:B2) does not auto-expand inside ARRAYFORMULA when new Google Form rows arrive.
Fix: For true auto-expanding single-cell running balances in Google Sheets, use =SCAN(0, B2:B6, LAMBDA(acc, val, acc + val)).
Mistake: Mixing text dashes ("-") instead of 0 in blank deposit rows breaks arithmetic running totals with #VALUE!.
Fix: Wrap amounts in N() or SUM() so non-numeric placeholders evaluate cleanly as 0.
Mistake: Dragging running balance formulas past the bottom row repeats the ending balance on empty ledger rows.
Fix: Guard empty entries with =IF(B2="", "", SUM($B$2:B2)).
Engineering Pro Tips
- To calculate a running balance across separate Credits (B) and Debits (C) columns, use =SUM($B$2:B2)-SUM($C$2:C2).
- Use =MAP(A2:A, B2:B, ...) or SCAN wrapped in IF(A2:A="", "", ...) to keep open-ended ledgers tidy.
- Always keep an explicit Opening Balance row at Row 2 if bank reconciliations start from an existing cash balance.
Frequently Asked Questions
- Why use SCAN + LAMBDA instead of SUMIF(ROW(...))?
- SUMIF over ROW compares N² pairs and slows down large sheets, while SCAN runs in fast linear O(N) time.
- How do I stop SCAN from calculating blank rows at the bottom?
- Use =SCAN(0, B2:B, LAMBDA(a, v, IF(v="", "", a + v))) or wrap with FILTER.
- Does this work with negative debits and positive credits?
- Yes, negative numbers reduce the running balance accurately.
Related Formulas & Guides
- Split and Reformat Comma-Separated Values in Google Sheets — Split comma-separated tags or reformat delimited lists cleanly in Google Sheets using SPLIT, TRIM, and TEXTJOIN. Test live in our grid.
- Count Distinct Values with Criteria Using COUNTUNIQUEIFS — Count distinct users, orders, or accounts meeting multiple filter conditions in Google Sheets using COUNTUNIQUEIFS and live examples.
- Join All Matching Values Into One Cell (TEXTJOIN + FILTER) — Concatenate all matching values from a Google Sheets column into one comma-separated cell using TEXTJOIN and FILTER. Test live now.
- Google Sheets SUMIFS Date Range Formula Guide — Sum Google Sheets values between two dates with SUMIFS or QUERY. Copy the verified syntax and test live in our interactive spreadsheet.