
π This article includes 1 downloadable practice file β
REDUCE and SCAN walk through a list one item at a time, carrying a running value (the accumulator).
=REDUCE(start, list, LAMBDA(acc, item, new_acc)) β only the final value
=SCAN(start, list, LAMBDA(acc, item, new_acc)) β every step
Running bank balance
=SCAN(1000, {-200, 500, -300}, LAMBDA(bal, txn, bal + txn)) β 800, 1300, 1000
=MIN(SCAN(...)) β 800, the lowest point
That lowest point is what a bank looks at for minimum-balance charges, and it’s one formula.
MULTIREPLACE: many SUBSTITUTEs in one
MULTIREPLACE =LAMBDA(t, old, new,
REDUCE(t, SEQUENCE(COLUMNS(old)),
LAMBDA(a, i, SUBSTITUTE(a, INDEX(old, i), INDEX(new, i)))))
=MULTIREPLACE("ABC Pvt Ltd", {"Pvt","Ltd"}, {"Private","Limited"}) β ABC Private Limited
Point old and new at two columns of a table and your replacement list becomes editable without touching the formula. Turn the columns into rows with TRANSPOSE, or use ROWS instead of COLUMNS.
=REDUCE(0,B2:B6,LAMBDA(a,v,a+(v>100))). For simple counts COUNTIF is faster, but the pattern works for rules COUNTIF can’t express.Common mistakes
- Argument order inside the LAMBDA: always (accumulator, item).
- Returning an array from REDUCE needs care; for lists of results use SCAN or MAP.
Practice
Download the workbook below. The tasks call each function inline, like =LAMBDA(x,x*2)(A2), so the file works on any Microsoft 365 PC; in your own files, save them by name in Name Manager. The Check column turns green when you’re right.
π Practice files for this article
- πLesson 5 practice workbook6 REDUCE/SCAN tasks with checks.β¬ XLSX Β· 14 KB
Free to use for learning. Files with macros (.bas) are plain text β import them with Alt+F11 β File β Import File, and always test on a copy.
Stuck on a step? Ask a question and the AI answers using this article.