How to fill blank cells with the value above in Excel

A category typed once, with blanks underneath, should repeat until the next category. Austin, a blank, a blank, and Dallas become Austin, Austin, Austin, Dallas. That is the list on the fill down page. It is not the city list on How to count unique values in Excel. That list has no blanks: Austin, Dallas, Austin, Houston.

The copy-down looks up one row

The filled column starts with the first city. Each row under it uses the cell above when its own city cell is empty.

IF
=IF(A3="",B2,A3)
=IF(A3="",B2,A3)B3
Copy down
AB
1CityFilled
2AustinAustin
3Austin
4Austin
5DallasDallas
A picture of Austin, two blanks, and Dallas. Each filled cell keeps the value above when its own cell is empty. The result is Austin, Austin, Austin, Dallas.
=A2
=IF(A3="",B2,A3)
=IF(A4="",B3,A4)
=IF(A5="",B4,A5)

Row 3 is empty, so it keeps Austin. Row 4 is empty, so it keeps the Austin that row 3 just filled. Row 5 is Dallas, so the run changes. The test is ="". A formula that returns "" counts as empty. The number 0 does not. A cell with a space does not. The fill-down page states both of those limits.

This copy-down works in older Excel. It has to be filled in order, from the top. A row that points at the original column instead of the filled column stops at the first blank and returns a blank.

SCAN spills the same four results

SCAN walks the column once. The accumulator starts as an empty string. An empty cell keeps the accumulator. Any other cell replaces it.

SCAN
=SCAN("",A2:A5,LAMBDA(acc,v,IF(v="",acc,v)))
=SCAN("",A2:A5,LAMBDA(acc,v,IF(v="",acc,v)))B2
One spill
AB
1CityFilled
2AustinAustin
3Austin
4Austin
5DallasDallas
A picture of the same four cells as one SCAN. The first result is Austin. The two blanks stay Austin. Dallas starts a new run.
=SCAN("",A2:A5,LAMBDA(acc,v,IF(v="",acc,v)))
=xl.fill.down(A2:A5)

The spill is Austin, Austin, Austin, Dallas. xl.fill.down is that SCAN under a name. The name needs Microsoft 365, Excel 2024, or Excel for the web. Excel 2021 returns #NAME? for LAMBDA. The copy-down above is the sheet that still opens there.

The spill is as tall as the four input cells. It does not insert rows. A blank above the first Austin would stay blank, because the accumulator has not seen a city yet.


More from the blog