首页 > 解决方案 > Copy value from a cell to the rest of a colum

问题描述

Is there someone who can help me to break down this long formula and ,by examining the independent elements, help us to understand how it works?

It takes two contiguous columns, in this case A and B. First a value from A is taken. If there is a next value down A, it will repeat the actual value until that row. If there's no values left in A, it return "" (blank)

So, in "B1" we write this very long formula:

ArrayFormula(IF(ROW(A:A)<=MATCH(2;1/(A:A<>"");1);LOOKUP(ROW(A:A);ROW(A:A)/IF(A:A<>"";TRUE;FALSE);A:A);))

The result is like this:

A B
foo foo (here goes the formula)
foo
bar bar
bar
bar
qux qux
" "
" "
" "
" " (blank cells continue till the end of column)

This array is quite useful, but I guess if there is a cleaner formula, or a better approach to this task... I suspect thats this formula is a turnaround and Spreadsheets must have an elegant resource to get done this kind of task.

标签: google-sheetsarray-formulas

解决方案


利用:

=ARRAYFORMULA(IF(B:B="",, VLOOKUP(ROW(A:A), IF(A:A<>"", {ROW(A:A), A:A}), 2, 1)))

推荐阅读