You can create a matrix like this:
=arrayformula( if( sequence(1, max(A1:A)) <= A1:A, sequence(1, max(A1:A)), iferror(1/0) ) )
The formula uses the open-ended reference A1:A
, and will thus process all rows in column A
. If you want to limit the formula to a predefined number of rows, use a bounded reference like A1:A42
.
To limit the formula to the continuous rows where column A
contains a number, use filter()
, like this:
=arrayformula( if( sequence(1, max(A1:A)) <= filter(A1:A, isnumber(A1:A)), sequence(1, max(A1:A)), iferror(1/0) ) )
To limit the formula to the last row that contains a number, use the max(row() * isnumber())
pattern, like this:
=arrayformula( if( sequence(1, max(A1:A)) <= filter(A1:A, row(A1:A) <= max(row(A1:A) * isnumber(A1:A))), sequence(1, max(A1:A)), iferror(1/0) ) )
A suggested edit proposed to use indirect()
for the same purpose. indirect()
is a volatile function that gets recalculated every time any value in the spreadsheet is edited. It thus hurts spreadsheet performance and is best avoided.