Array Transformation functions

ARESIZE

Reference

» Reference, Discussion, & Example Applications:

About

Resizes an array to a specified dimension.

Inputs:

  • a : array
  • [r] : new row number
  • [c] : new column number

More Info:

  • 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.

Code

M.S. Excel
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), "")
    )
);