Google Sheets function · Lookup
ROW in Google Sheets: syntax and examples
ROW returns the row number of a cell, with row 1 at the top. Given a range, it returns only the first row number, unless the formula runs inside ARRAYFORMULA, where you get one number per row. It is the usual building block for counters and position formulas.
Syntax
ROW([cell_reference])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
cell_reference | reference | no | The cell or range to read the row from. Without it, the row of the cell holding the formula. |
Examples
The examples use this table, starting in A1:
| Item | Qty |
| Lamp | 3 |
| Chair | 5 |
| Desk | 2 |
=ROW(C5)Result: 5
The row number of one cell.
Run in a Google Sheet (English US locale) on .
=ROW(A2:A4)Result: 2
A range on its own returns only its first row number.
Run in a Google Sheet (English US locale) on .
=SUM(ARRAYFORMULA(ROW(A1:A3)))Result: 6
Inside ARRAYFORMULA the range gives all its row numbers, so SUM adds 1, 2 and 3.
Run in a Google Sheet (English US locale) on .
=ARRAYFORMULA(ROW(A2:A4) - 1)Result:
| 1 |
| 2 |
| 3 |
A running counter that starts at 1 beside a list.
Run in a Google Sheet (English US locale) on .
=INDEX(A1:B4, ROW(A3), 1)Result: Chair
Use ROW as the row argument of INDEX to read the third row.
Run in a Google Sheet (English US locale) on .
Common errors
- Without an argument, ROW() gives the row of the cell that holds the formula.
- A range on its own returns only the first row number: ROW(A5:C7) is 5. Wrap it in ARRAYFORMULA to get 5, 6 and 7.
- Even a multi-column range such as A5:C7 gives a single column of row numbers inside ARRAYFORMULA, one per row.
- The argument must be a reference. Text such as "a" returns #N/A.
Compared with Excel
Same syntax in Excel.
Questions and answers
How do I number rows automatically in Google Sheets?
Put =ARRAYFORMULA(ROW(A2:A4) - 1) in the first cell beside the list. Each row gets its own number starting at 1. Change the range to match the length of your list.