Skip to content

ROW

Returns the row number of a reference, or of the cell the formula is in. Use it for automatic numbering and for building row-based formulas.

Syntax

=ROW()

Lookup and reference

Every version of Excel, including Microsoft 365, Excel 2024, 2021, 2019, 2016 and earlier, Excel for the web and the mobile apps.

Try it

Edit the formula in B2 or change the inputs. The sheet recalculates as you type.

B2
A
B
C
D
1
Cell
Row number
2
C5
5
3
4
5
6

B2 =ROW(C5) returns 5

How ROW works

ROW returns a row number. =ROW(C5) returns 5, and =ROW() returns the number of the row the formula sits in. It looks too simple to matter, but it is the foundation of automatic numbering, alternating-row logic and many array formulas.

The argument

reference is optional.

  • With a single cell, =ROW(C5) returns 5.
  • With nothing, =ROW() returns the row of the cell holding the formula.
  • With a multi-row range, such as =ROW(B3:B5), older versions of Excel return only the first row, 3. Microsoft 365 and Excel 2021 or later return all of them as an array, {3;4;5}, which spills into neighbouring cells. Inside a function such as SUMPRODUCT or INDEX, that array is what makes row-by-row calculations work.

Common uses

  • Automatic numbering. =ROW()-ROW($A$1) in the first row below a header gives 1, and fill-down gives 2, 3, 4, and so on. Anchoring on the header cell means the numbers stay correct if rows are added above the table. A fixed =ROW()-1 breaks when the header moves.
  • Alternating logic. =IF(MOD(ROW(),2)=0,"Even","Odd"), or the same test inside conditional formatting, picks out every other row.
  • Position within a range. =ROW(C5)-ROW(C$1)+1 is the position of C5 within a list that starts at C1. It is useful inside INDEX when you build a formula that must keep working as rows are inserted.
  • Counting up a sequence. =ROW(A1) filled down gives 1, 2, 3, because the reference shifts as it is copied. Be aware that this goes wrong if someone deletes row 1.

ROW, ROWS and SEQUENCE

ROW tells you where something is on the sheet. ROWS tells you how many rows a range has, and COLUMN is the matching function for columns. If all you want is a list of numbers, SEQUENCE in Microsoft 365 is simpler than ROW tricks: =SEQUENCE(10) returns 1 to 10.

Things to be careful about

ROW reports the position on the sheet, not within a table. If someone inserts or deletes rows above your data, ROW values change, so a formula that uses ROW()-1 to mean "item number" breaks. Subtract the row of the header cell instead, as above. ROW also isn't volatile: it recalculates only when its reference moves.

Arguments

referenceoptional
The cell or range whose row number you want, such as C5. If you leave it out, ROW returns the row of the cell the formula is in. For a multi-row range, current Excel returns every row number as an array that spills.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

The row number of a cell

B2 =ROW(C5)

Result: 5

C5 is in row 5. The column letter doesn't matter, only the row.

B2
A
B
C
D
1
Cell
Row number
2
C5
5
3
4
5
6

B2 =ROW(C5) returns 5

Example 2

Automatic numbering that survives inserted rows

A5 =ROW()-ROW($A$1)

Result: 4

ROW() is 5 in A5, and the header row ROW($A$1) is 1, so the result is 4. Fill the formula from A2 down and the numbers run 1, 2, 3, 4. Anchoring on the header means rows added above the table don't break it.

A5
A
B
C
1
No.
Task
2
Order stock
3
Check invoices
4
Book carrier
5
4
Send report
6
7

A5 =ROW()-ROW($A$1) returns 4

Example 3

Alternate rows: odd or even

B2 =IF(MOD(ROW(),2)=0,"Even","Odd")

Result: Even

B2 is in row 2, an even row, so MOD(2,2) is 0 and the result is Even. Filled down, B3 shows Odd, B4 Even, and so on.

B2
A
B
C
1
Invoice
Group
2
INV-3101
Even
3
INV-3102
4
INV-3103
5
INV-3104
6

B2 =IF(MOD(ROW(),2)=0,"Even","Odd") returns Even

Example 4

Every row number in a range

C2 =ROW(A3:A5)

Result: 3; 4; 5

In Microsoft 365 and Excel 2021 or later, a multi-row reference returns an array of row numbers that spills down from C2. In Excel 2019 and earlier, you would get only 3.

C2
A
B
C
D
E
1
Region
Rows
2
3
3
North
4
4
South
5
5
East
6

C2 =ROW(A3:A5) returns 3; 4; 5

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In A2, number the first task using the row number, so that it shows 1, and fill it down to A7 so the list runs 1 to 6. Anchor on the header so it survives inserted rows above the table.

Answer in A2, then it fills down to A7.

A2
A
B
C
D
1
No.
Task
Group
2
Order stock
3
Check invoices
4
Book carrier
5
Send report
6
Archive files
7
Update tracker
8

Common mistakes

  • =ROW()-1 as an item number breaks when someone inserts a row above the table or moves the header. Subtract the header cell's row instead: =ROW()-ROW($A$1).
  • =ROW(A1) filled down gives 1, 2, 3 only while row 1 exists. If someone deletes row 1, the formulas turn into #REF!.
  • ROW returns the position on the sheet, not within a table or a filtered list. Hidden and filtered-out rows still count.
  • A multi-row range spills in current Excel. If neighbouring cells aren't empty you get #SPILL!. Wrap the range in INDEX or MIN to return one number.
  • In Excel 2019 and earlier a multi-row range returns only the first row number unless the formula is entered as an array formula.

Questions people ask

What does ROW() return with no argument?

The row number of the cell that holds the formula. In B7, `=ROW()` returns 7.

How do I number rows automatically in Excel?

Put `=ROW()-ROW($A$1)` in the first row under the header and fill down, where $A$1 is the header cell. For a simple list in Microsoft 365, `=SEQUENCE(10)` also works.

What is the difference between ROW and ROWS?

ROW returns the row number of a cell, such as 5 for C5. ROWS returns how many rows a range contains, such as 8 for A2:A9.

Why does ROW return several numbers?

In Microsoft 365 and Excel 2021 or later, ROW of a multi-row range returns an array with one number per row, and it spills into the cells below. Use MIN(ROW(range)) for the first row only.

Learn ROW in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.