Skip to content

ARRINS

>> Reference, Discussion, & Example Applications:

“Intercalates” rows or columns of 2 arrays.

Calls ABLNKINS.

  • ar : array to receive the insert
  • br : array to be inserted
  • [rc] : rows/columns orientation: if omitted or 0, by rows; if 1 by columns
  • [h] : headers array

NOTE: Arrays should be proportionate by nr. of elements and to share one dimension.

ARRINS = LAMBDA(ar, br, [rc], [h],
LET(
a, IF(ar = "", "", ar),
b, IF(br = "", "", br),
o, IF(rc, -1, 1),
k, o * COUNTA(a) / COUNTA(b),
x, ABLNKINS(a, k),
v, IFNA(IF(rc, HSTACK(x, ""), VSTACK(x, "")), ""),
y, ABLNKINS(b, o * 1, -ABS(k)),
z, IF(v = "", y, v),
IF(AND(h = ""), z, IF(rc, HSTACK(h, z), VSTACK(h, z)))
)
);