Skip to content

ARESIZE

>> Reference, Discussion, & Example Applications:

Resizes an array to a specified dimension.

  • a : array
  • [r] : new row number
  • [c] : new column number
  • if r/c omitted, array not resized, only errors/blanks replaced with null strings.
  • if only one of the r/c arguments is omitted, the function calculates the smallest other argument to accommodate all elements of initial array.
ARESIZE = LAMBDA(a, [r], [c],
LET(
x, ROWS(a),
y, COLUMNS(a),
t, x * y,
z, ROUNDUP(IF(r, r, IF(c, t / c, x)), 0),
w, ROUNDUP(IF(c, c, IF(r, t / r, y)), 0),
s, SEQUENCE(z, w),
q, QUOTIENT(s - 1, y) + 1,
m, MOD(s - 1, y) + 1,
IFERROR(INDEX(IF(a = "", "", a), q, m), "")
)
);