I want to abut multiple dynamically sized tables to each other where any one of the tables may be empty.
For example, say I have the following:
where A3
has the following formula:
=LET(
a, MAKEARRAY(5, A1, LAMBDA(x,y, "hello")),
b, MAKEARRAY(5, B1, LAMBDA(x,y, "world")),
c, MAKEARRAY(5, C1, LAMBDA(x,y, "!")),
final, HSTACK(a,b,c),
final
)
What I want is to produce the following, if say, B1
is set to 0
:
My attempt starts here
If any of A1
, B1
, or C1
are set to 0, the MAKEARRAY
function results in an #VALUE!
error instead of elegantly producing a 0x0 array that HSTACK could ignore...
I tried to make up for this by using IFERROR
and creating an empty column when a zero was used. Like so:
=LET(
a, MAKEARRAY(5, A1, LAMBDA(x,y, "hello")),
b, MAKEARRAY(5, B1, LAMBDA(x,y, "world")),
c, MAKEARRAY(5, C1, LAMBDA(x,y, "!")),
err, MAKEARRAY(5, 1, LAMBDA(x,y, "")),
final, HSTACK(IFERROR(a, err), IFERROR(b, err), IFERROR(c, err)),
final
)
which produces produces this:
To get rid of the empty column, I tried this using a BYCOL
to create a mask and then FILTER
:
=LET(
a, MAKEARRAY(5, A1, LAMBDA(x,y, "hello")),
b, MAKEARRAY(5, B1, LAMBDA(x,y, "world")),
c, MAKEARRAY(5, C1, LAMBDA(x,y, "!")),
err, MAKEARRAY(5, 1, LAMBDA(x,y, "")),
stack, HSTACK(IFERROR(a, err), IFERROR(b, err), IFERROR(c, err)),
col_mask, BYCOL(stack, LAMBDA(col, COUNTBLANK(col)<>5)),
final, FILTER(stack, col_mask)
final)
which produces #CALC!
. I think this is due to the BYCOL(stack,...)
function call.
I think Excel can't handle array of arrays because if I split the BYCOL
and FILTER
into separate cells, this actually works. For example,
where A10
looks like:
=LET(
col_mask, BYCOL(A3#, LAMBDA(col, COUNTBLANK(col)<>5)),
final, FILTER(A3#, col_mask),
final
)
Is it possible to do this in a single cell without VBA?
BYCOL(stack, LAMBDA(col, COUNTBLANK(col)<>5))
this use thisBYCOL(stack,LAMBDA(α, AND(N(α<>""))))
you need to useAND()
and this is similar to useMMULT()
as well!!