SCAN and REDUCE in Excel: Running Totals and Custom Accumulators With LAMBDA

Isometric spreadsheet illustration showing SCAN in Excel accumulating running totals along a rising curve

Building a running cash balance or a cumulative sales total in Excel usually means writing a formula like =C8+B9 and dragging it down every time you add a new month. With SCAN in Excel and its summary partner REDUCE, you can loop through an entire range using a single LAMBDA formula—returning either every intermediate step (with SCAN) or just the final accumulated value (with REDUCE).

Availability & Compatibility: Per the official SCAN function documentation and REDUCE function documentation, SCAN is available in Excel for Microsoft 365 (Windows and Mac), Excel for the web, and Excel 2024, while REDUCE is available in Excel for Microsoft 365 and Excel for the web (both also work in Google Sheets). Older perpetual releases such as Excel 2021 and Excel 2019 do not support either function and will display #NAME?.

How SCAN in Excel Works (Dynamic Running Totals)

SCAN walks through an array one cell at a time, updates an accumulator variable on each step using your LAMBDA function in Excel, and spills an array containing every intermediate value. Here is the syntax:

=SCAN([initial_value], array, LAMBDA(accumulator, value, body))
  • [initial_value] (Optional): The starting value for the accumulator before the first element is processed. Set this to 0 for sums, 1 for multiplication, or "" when concatenating text.
  • array (Required): The range or dynamic array to scan from top-left to bottom-right.
  • lambda (Required): A two-parameter LAMBDA(a, v, body) where a holds the running accumulator and v holds the current cell value.

Suppose your Practice sheet tracks H1 2026 monthly net cash flows in B6:B11, with a starting cash balance of $10,000 in cell D4. To spill all six monthly running balances from one cell in D6, enter:

=SCAN(D4, B6:B11, LAMBDA(a, v, a+v))

Excel starts a at $10,000, adds January’s $3,200 to spill $13,200, subtracts February’s -$1,450 to spill $11,750, and continues automatically through June ($23,000)—no dragged formulas required.

How REDUCE Works (Return Only the Final Accumulated Value)

REDUCE uses the exact same three arguments as SCAN, except instead of spilling every intermediate step, it returns only the final value stored in the accumulator:

=REDUCE([initial_value], array, LAMBDA(accumulator, value, body))

Think of REDUCE as a custom, conditional aggregator when built-in functions like SUMIF or PRODUCT fall short. For example, to sum only positive cash inflows in B6:B11 starting from 0:

=REDUCE(0, B6:B11, LAMBDA(a, v, IF(v>0, a+v, a)))

This returns $15,350 as a single scalar value. If you ever need row-by-row or column-by-column summaries across a 2D table instead of sequential accumulation, pair these techniques with BYROW and BYCOL in Excel.

SCAN vs. REDUCE vs. Classic Running-Total Formulas

Use this comparison table to pick the right accumulator approach for your workbook:

MethodOutput ShapeSupports Resets / Conditions?CompatibilityBest For
SCANFull spilled array (every step)Yes (via IF inside LAMBDA)M365, Excel 2024, SheetsRunning balances, streak counters
REDUCESingle final valueYes (via IF inside LAMBDA)M365, Excel for web, SheetsConditional products, custom totals
Dragged =C8+B91 cell per copyManual edits requiredAll Excel versionsLegacy Excel 2021/2019 sharing

Troubleshooting #VALUE!, Initial-Value Bugs, and #SPILL! Errors

  • #VALUE! error (“Incorrect Parameters”): Per Microsoft Support, SCAN and REDUCE require a LAMBDA with exactly two parameters (accumulator and value). Passing one or three parameters triggers #VALUE!.
  • Multiplication always returns 0: If you omit initial_value or pass 0 when multiplying inside REDUCE or SCAN, every step multiplies by zero. Always set initial_value to 1 for products and "" for text strings.
  • #SPILL! error with SCAN: Clear any existing values or merged cells below the formula cell—see our guide on how to fix the #SPILL! error in Excel.
  • #NAME? error: The workbook was opened in Excel 2021 or older, where SCAN and REDUCE are unavailable.

Frequently Asked Questions

Download the practice workbook

The same data as this tutorial, with empty answer cells and a Solutions sheet.

Team Xl in Excel

Team Xl in Excel

Spreadsheet Architect & Educator at Xl in Excel. Sharing advanced formulas, dynamic arrays, and clean data modeling techniques.

Learn More About Team Xl in Excel →

Leave a Reply

Your email address will not be published. Required fields are marked *

Zoom: 100% | UTF-8 | Xl in Excel