27

In a Google Docs Spreadsheet, I would expect this formula:

=ARRAYFORMULA(ROW())

to fill the column like:

[   1]
[   2]
[   3]
[   4]
  ...

but instead it stops at 1. What is happening here? Is there another way to get the current row number in an arrayformula?

4 Answers 4

31

You need to specify a cell-range argument for ROW() in order to have more than one value.

Try it this way:

=ARRAYFORMULA(ROW(A1:A10))

This will fill a column with row numbers from 1 to 10.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, this makes sense now! I wanted it to fill the sheet and expand when rows are added, so I used: =ARRAYFORMULA(ROW(A2:A)) (starting under the header row)
If I need to be certain the numbers returned match the actual sheet row numbers they are on, but don't know which row the formula is starting on, is there a simpler method than this? =ARRAYFORMULA(ROW(INDIRECT(CONCATENATE("A",ROW(),":A"))))
19

The following may be a little simpler:

=arrayformula(ROW(INDIRECT("A"&ROW()&":A")))

or

=index(ROW(INDIRECT("A"&ROW()&":A")))

Comments

0

This works when you want row number limited to not-empty row

=ARRAYFORMULA(filter(ROW(INDIRECT(CONCATENATE("A";ROW();":A")));A2:A<>""))

Comments

0

Put this on the 1st Column header

=arrayformula({"NO.";IFERROR(IF(B2:B<>"",ROW(INDIRECT("A"&ROW()&":A")),""))})

If you have an error saying:

"Circular dependency detected. To resolve with iterative calculation, see File > Settings."

Go to File > Settings > Calculation Tab > Iterative calculation

2 Comments

I have an error with this formula: "Circular dependency detected. To resolve with iterative calculation, see File > Settings."
Go to File > Settings > Calculation Tab > Iterative calculation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.