'Array formula to fill a sequence of n numbers in a column

I have a Google sheet that has a sequence of numbers in the left column:

Sample Database

I'd like to write an array formula in A1 that automatically adds the next number in the sequence when a new row is added to the sheet.

For example, if I add a row 8, an 7 (the next number in the sequence) automatically fills in cell A8. I've tried this with the Sequence function, but that requires a pre-defined number of rows. I've also tried to do an array formula that uses something like "A3=A2+1", but I can't get the syntax to work in an array.



Solution 1:[1]

Try the following in cell A1:

={"Sequence";sequence(rows(A2:A))}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ztiaa