Google-sheets – Return value in column A in preceding cells in column B using an array formula

formulasgoogle sheets

How do you fill cells in column B (using an array formula) that are preceding the cell in column A with the value of column A only when cell in column C is not blank?

In other words, after column C is filled with text values, in the next empty row I enter a text value in column A, then I want the preceding cells in column B where column C is not empty to be filled with this manually entered value in column A, like this:

A   B   C
    d   notblank
    d   notblank
    d   notblank
d
    a   notblank
    a   notblank
    a   notblank
    a   notblank
a
    e   notblank
    e   notblank
e

Best Answer

Assuming the data starts in row 1, try in B1:

=ArrayFormula(IF(LEN(A:A)=0,VLOOKUP(ROW(A:A),{{0;FILTER(ROW(A:A),LEN(C:C)=0)},{FILTER(A:A,LEN(C:C)=0);""}},2),))


Out of interest, the formula simplifies a bit if you are retrieving from cells below:

=ArrayFormula(IF(LEN(A:A)=0,VLOOKUP(ROW(A:A),FILTER({ROW(A:A),A:A},LEN(C:C)=0),2),))