SCAN Function

Excel Functions › Logical

Excel 365

The Excel SCAN function walks through an array carrying an accumulator, applies a LAMBDA at each step, and — here’s its signature move — returns the array of every intermediate result. One formula produces a whole running-total column that resizes itself with the data. Its sibling REDUCE does the identical walk but keeps only the final value; SCAN shows the journey, REDUCE shows the destination.


Quick answer: a running total of B2:B6 in a single spilled formula:
=SCAN(0, B2:B6, LAMBDA(acc, v, acc + v))
Start the accumulator at 0, add each value, and SCAN emits the balance after every step: 500, 800, 1250, 1450, 1800. Excel 365 only.

Syntax

=SCAN([initial_value], array, lambda(accumulator, value, calculation))
ArgumentDescription
initial_valueOptionalThe accumulator’s starting value — 0 for sums, 1 for products, "" for text building. Omitted, it defaults from the first element, which can surprise you; stating it is good practice.
arrayRequiredThe range or array to walk through. SCAN’s output has exactly the same shape.
lambdaRequiredA LAMBDA taking two parameters: the accumulator (the running result so far) and the current value. Whatever it returns becomes both this position’s output and the next step’s accumulator.

Available in: Excel for Microsoft 365 (and Excel for the web) only — it is not in Excel 2021. Older versions show #NAME?. The result is a dynamic array that spills to match the input’s shape.

Running totals: the classic SCAN

Monthly deposits sit in B2:B6. One formula in D2 produces the entire balance column:

ABD
1MonthDepositBalance
2Jan500500
3Feb300800
4Mar4501,250
5Apr2001,450
6May3501,800
=SCAN(0, B2:B6, LAMBDA(acc, v, acc + v)) // spills 5 running balances into D2:D6

Each step the LAMBDA receives the balance so far (acc) and the new deposit (v), returns their sum, and that sum is recorded and passed forward. Add a June row to the source and the spill grows by itself — no formula to drag down.

The old-school equivalent =SUM($B$2:B2) dragged down a column still works, but it is one formula per row and breaks when rows are inserted above the anchor.

Try it: interactive SCAN demo

Live demo

Edit the comma-separated deposits and watch SCAN rebuild the running total — and note what REDUCE would keep from the same walk.

Beyond sums — and SCAN vs REDUCE

Change the LAMBDA and SCAN computes any cumulative sequence:

=SCAN(1, B2:B13, LAMBDA(acc, v, acc * v)) // running product - compound growth factors
=SCAN(0, B2:B100, LAMBDA(acc, v, MAX(acc, v))) // running maximum - record high to date
=SCAN("", A2:A6, LAMBDA(acc, v, TEXTJOIN("-", , acc, v))) // building text breadcrumb step by step

SCAN vs REDUCE is the question everyone asks. Both walk the array with an accumulator and the same LAMBDA shape; the difference is purely what they return:

=SCAN(0, B2:B6, LAMBDA(a, v, a+v)) // returns {500; 800; 1250; 1450; 1800} - every step
=REDUCE(0, B2:B6, LAMBDA(a, v, a+v)) // returns 1800 - the final value only

Want the whole trail — balances, cumulative counts, running records? SCAN. Want one answer at the end of the walk? REDUCE. For element-wise transforms with no memory between steps, that’s MAP. Wrap any of them in LET when the pieces get long.

Errors & common pitfalls

#NAME? — not an Excel 365 workbook. SCAN exists only in Excel for Microsoft 365 and Excel for the web — not Excel 2021, not 2019. There is no non-365 equivalent short of helper columns.

#VALUE! — the LAMBDA has the wrong shape. SCAN’s LAMBDA must take exactly two parameters — accumulator first, then value. One parameter or three, and the call fails.

#SPILL! — no room for the output. SCAN returns an array the same size as its input; anything sitting in the landing zone blocks it. Clear the cells below/beside the formula.

Pitfall: skipping initial_value. It is technically optional, but relying on the default makes the first step behave differently from the rest. State it: 0 for sums, 1 for products, "" for text.

Pitfall: 2-D ranges walk row by row. On a multi-column range, SCAN runs left-to-right then top-to-bottom, carrying the accumulator across row breaks, and returns the same 2-D shape. For per-row results, combine BYROW with a per-row SCAN or restructure with TOCOL first.

Practice workbook

📊
Download the free SCAN practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

What's the difference between SCAN and REDUCE?
Same walk, different output. Both carry an accumulator through the array with your LAMBDA, but SCAN returns every intermediate result as a spilled array, while REDUCE returns only the final value. Running balance column = SCAN; single grand total = REDUCE.
How do I make a running total with SCAN?
=SCAN(0, B2:B100, LAMBDA(acc, v, acc + v)) — start at 0, add each value, and the formula spills the balance after every row. It grows automatically when the source range grows.
Which Excel versions support SCAN?
Excel for Microsoft 365 and Excel for the web only. It is not included in Excel 2021 or any perpetual-license version, where the name isn't recognized.
What does the LAMBDA inside SCAN need to look like?
Exactly two parameters, accumulator first: LAMBDA(acc, v, calculation). The calculation's result is written to the output and becomes the next step's acc. A different parameter count fails the call.
Can SCAN do a running product or running maximum?
Yes — change the LAMBDA body: =SCAN(1, rng, LAMBDA(a,v, a*v)) compounds a product; =SCAN(0, rng, LAMBDA(a,v, MAX(a,v))) tracks the record high so far.
How does SCAN handle a multi-column range?
It walks left-to-right, top-to-bottom, carrying the accumulator across rows, and returns an array of the same 2-D shape. For independent per-row running totals, pair BYROW with SCAN or flatten with TOCOL first.

Master functions like this in one day

This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related functions: REDUCE · MAP · LAMBDA · BYROW · BYCOL · MAKEARRAY · LET