LAMBDA · Dynamic arrays

Fill down LAMBDA

xl.fill.down copies the last non-blank value through the blanks under it. Austin, a blank, a blank, Dallas becomes Austin, Austin, Austin, Dallas.

Microsoft 365, Excel 2024, and Excel for the web. Excel 2021 does not have LAMBDA.

Syntax =xl.fill.down(values)

xl.fill.down
=LAMBDA(values,
  SCAN("", values, LAMBDA(acc, v, IF(v="", acc, v)))
)

Arguments

NameRequiredWhat to pass
valuesRequiredA column. A blank cell keeps the value above. A non-blank cell starts a new run.

Examples

A city carried through two blank rows

=xl.fill.down(A1:A4)

Result Austin, Austin, Austin, Dallas

=SCAN("",A1:A4,LAMBDA(acc,v,IF(v="",acc,v)))B1
Fill
AB
1AustinAustin
2Austin
3Austin
4DallasDallas
A picture of the sheet, not a live calculator. B2:B4 are the spill.

xl.fill.down is the fill-handle job as a formula. A category typed once at the top of a block, with blanks underneath, is copied down until the next category. Austin, blank, blank, Dallas becomes Austin three times and then Dallas.

A formula that returns "" is treated as blank. The number 0 is not.

Add it to the workbook

Copy the formula in the block above, including the line breaks. Choose Formulas, Name Manager, New. Set the name to xl.fill.down, the scope to Workbook, and paste into Refers to. Excel Labs can do the same step: open the Advanced Formula Environment, add that name, and save it back to the workbook. A cell then calls =xl.fill.down(...).

The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA even when it already has XLOOKUP, FILTER, or LET.

How it works

SCAN walks the column and keeps an accumulator. The LAMBDA returns the accumulator when the cell is empty and returns the cell when it is not. The first blank, before any value, stays blank because the accumulator starts as an empty string.

Limits

The test is v="". A space is not blank. Collapse spaces first if the export padded the cell. The spill is as tall as the input. It does not insert rows.