Spreadsheet Practice

ROW function

ROW returns the row number of a cell: ROW(C7) is 7, and ROW() with nothing inside returns the row of the cell the formula sits in. It numbers lists automatically, turns position into a count inside other formulas, and drives rules such as shading every other row.

Available in
Every current version
Category
Lookup functions
Returns
A row number. Given a range of several rows, Microsoft 365 returns each row number as a spilled list.
Google Sheets
Works the same way in Google Sheets.

Syntax

=ROW([reference])

ArgumentRequired?What it is
referenceOptionalThe cell to get the row number of. Leave it out to use the formula's own cell.

Examples

Each result below is calculated from the sample sheet by our formula engine, the same one that grades the practice.

CellFormulaResultWhat it shows
D2=ROW()2The row of the formula's own cell
D3=ROW(A5)5The row of the cell you point to
D4=ROW()-ROW($A$1)3Numbers rows from 1 under the header: this is the third item

Try it live

This is the sample sheet. Change any number or text, or edit a formula, and the results update.

Show the sample data as a table
ItemQtyResult
Bolts1502
Nuts1505
Washers3003
Brackets40

Practice ROW

Graded instantly, then re-checked on changed data.

Running average

In C2, calculate the running average of orders: the total so far divided by the number of weeks so far. Get the number of weeks with ROW, then fill down to C7.

Common mistakes

What you seeWhy, and how to fix it
Numbers shift when rows are inserted above=ROW()-1 assumes the list starts in row 2. Subtract the header's row instead, =ROW()-ROW($A$1), so the numbering follows the table.
Mixing up ROW and ROWSROW returns a row number. ROWS counts the rows in a range.

Tips

  • =MOD(ROW(),2)=0 as a conditional formatting rule shades every other row.
  • In Excel 2021 or later, =SEQUENCE(10) numbers a list in one formula without filling down.

Questions

How do I number rows automatically in Excel?

Put =ROW()-ROW($A$1) in the first data row and fill down. The numbers stay in order after you sort or delete rows.

What does ROW() return with no argument?

The row number of the cell that contains the formula.

Last reviewed October 2026. Every example result on this page is calculated live by the Spreadsheet Practice formula engine.