How to Automatically Number Rows in Excel

“automatically number rows in excel” comes up constantly, so this page leads with the exact answer, and only then explains the detail. Everything works in Excel on Windows and Mac and maps almost one-to-one to Google Sheets. Copy the answer above and get back to work, or read on to turn a one-off fix into something you never have to look up again.

Exact answer

In Excel: put =ROW()-1 in the first data row and fill it down — the numbers then renumber themselves when rows are inserted, deleted or sorted, which typed numbers do not.

Annotated stepsExcel
1

Decide first whether the numbers must survive sorting; if so, they should be values, not formulas.

2

For a dynamic count, put =ROW()-1 in the first data row (adjust the −1 to your header row count).

3

Double-click the fill handle to run it to the bottom of the adjacent data.

4

On Microsoft 365 you can instead put =SEQUENCE(ROWS(B2:B500)) in one cell and let it spill.

5

Inside a Table use =ROW()-ROW(Table1[#Headers]) so new rows number themselves.

6

To freeze the result, select the column, Ctrl+C, then Paste Special ▸ Values.

=ROW()-1
Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

What this does

Three methods, and the differences matter. Typing 1 and 2, selecting both and dragging the fill handle produces STATIC numbers: fast, and wrong the moment anyone deletes row 7. =ROW()-1 (subtracting however many header rows you have) is dynamic — delete a row and the rest renumber instantly. =SEQUENCE(ROWS(A2:A500)) in Microsoft 365 spills a whole column of numbers from one formula. There is also a fourth case worth knowing: inside a Table, =ROW()-ROW(Table1[#Headers]) keeps numbering correct as the table grows, because it measures from the header rather than from the top of the sheet. If the numbers must be permanent — an invoice number, a record ID — a formula is the wrong tool: generate them once and paste as values, because an ID that changes when someone sorts the sheet is not an ID. The same idea underpins a lot of everyday Excel work, so the few minutes spent getting it right here pay back across every sheet you build afterwards. Treat it as a pattern, not a one-off, and it stops being something you look up and starts being something you reach for. Treat “automatically number rows in excel” as a small repeatable workflow rather than a one-off click you hope to remember next time. Use a small test block before the live file, so any surprise in the affected rows shows up while it is still harmless. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. That turns a workflow that saves repeating the same clicks every week into a method you can reuse, explain, and defend when the workbook leaves your screen.

A worked example

Data starts in row 2 under a header. A2: =ROW()-1 → 1, filled down to A500 → 499. Delete row 5 and the column reads 1,2,3,4,… with no gap. Compare with a typed fill: the same deletion leaves 1,2,3,5,6, and nobody notices until a total is quoted against the wrong count. A numbered column is usually there so people can refer to "row 14" in an email — which only works if the number still means the same row tomorrow. One habit worth forming early: name the cells that hold your inputs, so the formula reads in plain language instead of a string of cell addresses. A reviewer — or you in three months — can then follow the logic without decoding what B7 and D2 were supposed to mean, which is most of what makes a sheet maintainable.

In Google Sheets

If you are in Google Sheets rather than Excel, the good news is that the formula shown here is identical and the workflow barely changes — menus sit across the top instead of in a ribbon, and a few function names differ slightly, but anything you build here moves across with little or no rework. Nothing on this page is behind a login: the tool runs entirely in your browser, the formula is shown in full with one-click copy, and the steps work the same on Windows and Mac. That is the whole promise here — the exact answer, a way to prove it on your own numbers, and just enough context to make it stick. If you take one thing from this page on “automatically number rows in excel”, make it the habit rather than the keystrokes: set the problem up with labelled inputs, reference those cells, and let Excel do the recomputing. Bookmark the page for the syntax, but do the example once in a blank sheet and check it against the tool above — five minutes of hands-on practice fixes the method in memory far better than re-reading, and it surfaces the small snags while they are still harmless. After that the technique is genuinely yours: faster than searching for it again, and reliable enough to drop into work that other people depend on.

Common mistakes

  • Typing the numbers and then sorting or deleting rows, leaving a sequence with holes.
  • Forgetting to subtract the header rows, so the first data row is numbered 2.
  • Using =ROW() inside a Table and getting sheet row numbers rather than positions within the table.
  • Using a formula for invoice or record numbers, which then change under sorting — those must be static values.
  • Dragging one cell containing 1 instead of two cells containing 1 and 2, which copies 1 all the way down.

Frequently asked questions

How do I number rows in Excel?

Put =ROW()-1 in the first data row and fill down. Subtract as many as you have header rows.

How do I make the numbering update automatically?

Use a formula rather than typed numbers: =ROW()-1, or =SEQUENCE(ROWS(B2:B500)) on Microsoft 365. Both renumber after an insert or delete.

How do I fill a series of numbers?

Type the first two values, select both, and double-click or drag the fill handle. Excel continues the step it infers from the pair.

Why did my numbers stop matching after sorting?

They were typed values, so sorting moved them with their rows. A ROW-based formula recalculates to its new position.

Other ways people ask this

On the way here you may have searched this as “automatically number rows in excel”, “how do i automatically number rows in excel” and “excel formula to automatically number rows” — it is all the same task, and this page is the single, complete answer to it.

Why do people search for this in so many different ways?

Because the same task has many names. “automatically number rows in excel”, “how do i automatically number rows in excel”, “excel formula to automatically number rows” all point at the one operation explained on this page, which is why they all lead here.