ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Dynamic arrays
  3. Auto Number Rows in Excel (SEQUENCE and ROW)

Auto Number Rows in Excel (SEQUENCE and ROW)

By ExcelReady Team·Updated November 2, 2026·5 min read

The short answer

To auto number rows in Excel, type =ROW()-1 in A2 and fill it down: each row shows its own number and renumbers itself when rows are deleted. In Excel 2021 or Microsoft 365, =SEQUENCE(COUNTA(B2:B100)) numbers every filled row with one formula that grows as you add data. For fixed numbers, use the fill handle.

Key takeaways

  • =ROW()-1 in row 2 gives 1, and it renumbers itself when you delete or insert rows.
  • =SEQUENCE(COUNTA(B2:B100)) spills one number per filled row in Excel 2021 and Microsoft 365.
  • =IF(B2="","",COUNTA($B$2:B2)) numbers only the rows that have data.
  • =SUBTOTAL(103,$B$2:B2) numbers only the rows you can see after filtering.
  • Paste the numbers as values when an ID must stay with its row after sorting.
On this page+
  1. Which auto numbering method should you use?
  2. How to number rows with the fill handle
  3. How to auto number rows with ROW
  4. How to auto number rows with SEQUENCE
  5. How to number only rows that have data
  6. How to number visible rows after filtering
  7. How to keep numbers fixed or add leading zeros
  8. Practise it

To auto number rows in Excel, use a formula: =ROW()-1 gives each row its own number, and =SEQUENCE(COUNTA(B2:B100)) numbers a whole list with one formula. Typed numbers break as soon as you delete or insert a row, but formula numbers renumber themselves. This guide is for anyone keeping a numbered list of staff, orders or tasks, and it covers skipping blanks, numbering filtered rows and numbers that must never change.

Which auto numbering method should you use?#

Pick the method by what should happen when the list changes. All examples use a staff list with names in column B, starting in row 2, and the numbers in column A.

MethodFormula or actionUpdates after deleting rows?Excel version
Fill handle or Fill SeriesType 1, then fillNoAll
ROW=ROW()-1YesAll
SEQUENCE=SEQUENCE(COUNTA(B2:B100))Yes, and grows with the listExcel 2021, Microsoft 365
Skip blank rows=IF(B2="","",COUNTA($B$2:B2))YesAll
Visible rows only=SUBTOTAL(103,$B$2:B2)Yes, and follows filtersAll

How to number rows with the fill handle#

The fill handle is quickest for a list that won't change. It creates plain numbers, not formulas.

  1. Type 1 in A2 and 2 in A3.
  2. Select both cells.
  3. Drag the fill handle (the small square at the bottom-right of the selection) down, or double-click it to fill as far as the data in column B goes.

Excel continues the pattern: 3, 4, 5 and so on. For a long list, use Home > Fill > Series instead: choose Columns, a step value of 1 and a stop value such as 500.

The catch is that these numbers are fixed. Delete row 4 and the list jumps from 2 to 4. That's why the formula methods below are usually better. The Fill Down and Fill Right lesson practises filling with Ctrl+D (⌘D on a Mac).

How to auto number rows with ROW#

ROW returns the row number of the cell it's in. With headers in row 1, subtract 1 so the list starts at 1. In A2, type:

Excel formula
=ROW()-1

Fill it down. A2 shows 1, A3 shows 2, and so on. Delete a row and every number below it moves up by one, so the list never has gaps. Insert a row and you only need to fill the formula into the new cell.

If the list starts lower on the sheet, subtract the header's row number instead. With headers in row 4, use =ROW()-4. A version that doesn't depend on where the list starts is =ROW()-ROW($A$1), where A1 is the header cell.

In an Excel table, a formula in one cell fills the whole column automatically, and new rows get it too. Use =ROW()-ROW(Table1[#Headers]) so the numbers stay right even if the table moves. Replace Table1 with your table's name.

How to auto number rows with SEQUENCE#

In Excel 2021 and Microsoft 365, SEQUENCE makes a list of numbers from one formula. In A2, type:

Excel formula
=SEQUENCE(COUNTA(B2:B100))

COUNTA counts the filled cells in B2:B100, and SEQUENCE spills that many numbers down column A. With six names, you get 1 to 6. Add a seventh name and a 7 appears. You don't need to fill anything.

SEQUENCE takes up to four arguments: =SEQUENCE(rows, [columns], [start], [step]). So =SEQUENCE(5,1,10,10) returns 10, 20, 30, 40 and 50. Two things to know:

  • The cells below A2 must be empty. If anything is in the way, you see #SPILL!.
  • You can refer to the whole result as A2#, the spill reference. The modern Excel functions lesson practises spill references, and the guide to dynamic drop-down lists uses them as a list source.

COUNTA assumes the names have no gaps. If some rows in B are empty, use the next method.

How to number only rows that have data#

To leave blank rows unnumbered, count the filled cells from the top down to the current row:

Excel formula
=IF(B2="","",COUNTA($B$2:B2))

The range $B$2:B2 grows as you fill down: in row 5 it becomes $B$2:B5. COUNTA counts the names so far, and IF shows nothing for an empty row. If the gaps are mistakes, remove them instead; see how to delete blank rows in Excel.

How to number visible rows after filtering#

When you filter a list, ROW keeps the original numbers, so you might see 2, 5, 6. To number only the visible rows, use SUBTOTAL:

Excel formula
=SUBTOTAL(103,$B$2:B2)

Function number 103 means COUNTA that ignores hidden rows, so the count only includes rows you can see. Filter the list and the visible rows read 1, 2, 3 from the top, with no gaps. Function number 3 also ignores rows hidden by a filter, but 103 also ignores rows you hid by hand; see how to hide and unhide rows and columns.

How to keep numbers fixed or add leading zeros#

Formula numbers always follow the row's position. If you sort the list by name, the numbers stay 1, 2, 3 from the top, and they don't travel with each person. When a number is an ID that must stay with its row, freeze it:

  1. Select the numbers.
  2. Copy them (Windows: Ctrl+C; Mac: ⌘C).
  3. Paste as values: Home > Paste > Values, or Ctrl+Alt+V on Windows and ⌃⌘V on a Mac, then choose Values.

For numbers like 001, apply the custom number format 000 to the ROW formula. The value stays a real number but shows three digits; see custom number formats in Excel. For a text ID with a prefix, join it: ="EMP-"&TEXT(ROW()-1,"000") returns EMP-001 in row 2.

Practise it#

Try the exercise on this page: it numbers a row with ROW. Then practise Fill Down and Fill Right in a live spreadsheet to copy formulas down a column in one keystroke, and practise modern Excel functions and spill references to work with formulas like SEQUENCE that fill many cells at once.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Number the staff list with a formula. In A5, use ROW to show this row's number in the list (the header is in row 1), then press Enter.

fx
ABCD
1
No.
Name
Department
2
Grace
Sales
3
Omar
Finance
4
Lucia
Sales
5
Hiro
IT
6
Zainab
HR
7
Pavel
Finance
8
9
10

Tip: ROW() with nothing in the brackets returns the current row number. Subtract 1 for the header row.

Practise this in a lesson

LessonModern Excel: XMATCH, SORTBY, TEXTSPLIT and spill references (A2#)Split names with TEXTSPLIT, find positions with XMATCH, sort by another column with SORTBY, and refer to a whole spilled result with A2#.LessonFreeFill Down and Fill RightCopy a formula down a column or across a row in one keystroke.

Frequently asked questions

How do I auto number rows in Excel?

+

Type =ROW()-1 in the first data row (row 2) and fill it down. Each cell shows its row number minus the header row, so the list starts at 1 and stays in order when rows are deleted.

How do I auto number rows in Excel without dragging?

+

In Excel 2021 or Microsoft 365, type =SEQUENCE(COUNTA(B2:B100)) in A2. It spills a number for every filled cell in column B. In older versions, use Home > Fill > Series and enter a stop value.

How do I keep row numbers in order after deleting rows?

+

Use a formula instead of typed numbers. =ROW()-1 and SEQUENCE recalculate after you delete a row, so the list never has gaps.

How do I number rows starting from 001?

+

Use =TEXT(ROW()-1,"000") for text like 001, or keep =ROW()-1 and apply the custom number format 000. The format keeps the value a real number.

How do I number only visible rows after filtering?

+

Use =SUBTOTAL(103,$B$2:B2) in row 2 and fill it down. SUBTOTAL with 103 counts only visible cells, so the numbers restart at 1 for whatever the filter shows.

Sources

  • SEQUENCE function - Microsoft Support
  • Fill data automatically in worksheet cells - Microsoft Support
  • SUBTOTAL function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. Which auto numbering method should you use?
  2. How to number rows with the fill handle
  3. How to auto number rows with ROW
  4. How to auto number rows with SEQUENCE
  5. How to number only rows that have data
  6. How to number visible rows after filtering
  7. How to keep numbers fixed or add leading zeros
  8. Practise it

Keep reading

Productivity· 5 min read

Custom Number Formats in Excel

A custom number format changes how a number looks without changing its value. Select the cells, press Ctrl+1 (Mac: ⌘1), choose Custom and type a code in the Type box, such as 00000 for leading zeros, #,##0,"K" for thousands or 0 "kg" for units. Formulas still use the real number underneath.

Errors & fixes· 5 min read

Excel Date Showing as a Number? How to Fix It

Excel stores every date as a serial number, so 15 March 2024 is really 45366. When a date shows as a number, the cell has a General or Number format. Select the cells and choose Short Date on the Home tab, or press Ctrl+Shift+#. When you join a date to text, wrap it in TEXT, like TEXT(B2,"d mmm yyyy").

Productivity· 6 min read

How to Delete Blank Rows in Excel Safely

The safest way to delete blank rows in Excel is to filter. Turn on filters with Ctrl+Shift+L (Mac: ⌘⇧F), show only (Blanks) in a column that is always filled, select the visible rows and delete them with Ctrl+- (Mac: ⌘-). Then clear the filter. Avoid deleting every row that has any blank cell, because that removes real data too.

More on dynamic arrays

  • Count Unique Values With Criteria in Excel
  • Dynamic Arrays in Excel Explained Simply
  • Dynamic Drop-Down Lists in Excel That Update Themselves
  • Sum, Count or Average FILTER Results in Excel
  • FILTER by Date in Excel: Month, Range or Recent
  • How to Filter by a List of Values in Excel
All dynamic arrays articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free