FormulaCraft

How to number rows automatically in Excel and Google Sheets

Topic:Data cleaning & shaping
Excel & Google Sheets
=ROW()-1

Verified example

Computed by a real spreadsheet engine on the sample data below.

#Name
Alice
Bob
Carol
David
Eve

=ROW()-10

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

Step by step

  1. 1In cell A2 (assuming row 1 is the header) enter =ROW()-1 — this returns the current row number minus 1, giving 1 for row 2, 2 for row 3, and so on.
  2. 2Copy the formula down through all data rows.
  3. 3If your header is not in row 1, adjust the subtracted offset: if data starts in row 3, use =ROW()-2.

Tips

Working on a sheet you inherited? Run the Auditor on the whole file first — it flags every #REF!, #N/A, broken column pattern, and inconsistent formula in seconds, free, no signup.

Frequently asked

How do I number only rows that contain data (skip blanks)?

Use =IF(B2<>"",COUNTA($B$2:B2),"") — this counts non-blank cells from the top down, giving a sequential number only to filled rows.

Can I restart numbering at 1 for each group?

Yes — use COUNTIF to count occurrences of the group label so far: =COUNTIF($B$2:B2,B2) gives the within-group sequence number.

More on Data cleaning & shaping

See all →

Formulas used

Related tasks

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: