How to Auto Number Table Rows in Excel Workbooks

Automatically numbering rows in an Excel table can be very useful for organizing and analyzing data. Assigned row numbers make it easier to reference specific rows when sorting, filtering, or calculating values. Fortunately, Excel provides several straightforward methods to number table rows.

Why Auto Number Rows in Excel Tables

Here are some of the key reasons you may want to auto number rows in your Excel tables:

  • Easier Referencing – Being able to refer to a row as “Row 5” makes it simpler to work with large datasets. This beats trying to remember what specific data resides in unnamed rows.
  • Sorting/Filtering – When you sort or filter an Excel table, the rows get moved around. Row numbers that are independent of position make it easy to always identify individual rows.
  • Formulas – You can leverage the row numbers in formulas, such as looking up values from a different row. For example, =Table1[[#Headers],[@[Row]-1]] looks up the cell above.
  • Organizing Data – Grouping table rows into numbered sections can help organize data and make it more readable, especially in large tables.

Overall, auto numbering rows helps streamline working with Excel tables and prevents errors stemming from losing track of rows when manipulating data.

Method 1: Fill Handle to Number Rows

The fastest way to number rows in Excel is by using the fill handle:

  1. Type “1” into the first table row
  2. Click and drag the fill handle down to populate sequence
  3. Excel automatically increments numbers for each row


  • Very fast way to number many rows
  • Adjustable sequence (odd numbers, multiples, etc.)


  • Breaks if rows deleted/inserted
  • Requires starting value typed manually

Let’s look at an example:

Using fill handle to number rows

This method is great when you just need a quick sequence of row numbers. But it lacks flexibility if rows change.

Method 2: The ROW() Function

A more dynamic approach is to use Excel’s ROW() function to auto number rows:


How it Works

  • ROW() gives current row number
  • ROW($Table$1[#Headers]) returns header row number
  • Subtracting the two gives a unique counter


  • Numbers update automatically if rows added/deleted
  • Doesn’t require starting number typed


  • Slightly more complex formula

Let’s break down the formula:

=ROW() // Returns current row number, e.g. 7

-$Table$1[#Headers] // Structured reference for header row 


So if our header row is 4 and we’re on Row 7, we get:

7 - 4 = 3

The ROW() function makes it dynamic.

Method 3: The COUNTA() Function

An alternative to ROW() is using COUNTA() to number rows:



  • Handles filtered row numbering
  • Accounts for blank rows


  • More complex formula

COUNTA() allows continuous numbering even when rows are filtered out. This helps when you need to work with filtered tables but want an uninterrupted numbering scheme.

Custom Number Formatting

The above methods assign simple numbers to rows. But you can transform those numbers into custom formats:

  • Percentages
  • Scientific notation
  • Custom text
  • Date formatting
  • Currency


- [Row 1] -> 1  
- [Row 2] -> 2
- [Row 3] -> 3%
- [Row 4] -> $4
- [Row 5] -> 05-Jan 

This flexibility helps emphasize certain rows over others.

Steps to Custom Format

  1. Select column with row numbers
  2. Right-click > Format Cells
  3. Choose desired format from categories
  4. Click “OK”

Using Excel Tables

When numbering rows, Excel Tables provide useful benefits:

  • Automatic expanding/contracting
  • Structured references
  • Filtering
  • Dynamic formulas

Converting a range to a Table keeps everything neat when adding/removing rows. The formulas auto-fill without needing to drag down fill handles.

Excel Table

Convert Range to Table

  1. Select cell range
  2. Go to Insert tab
  3. Click Table
  4. Choose table formatting

After converting, the table expands/contracts as you add/remove rows. Any formulas fill automatically without needing to drag down each time.

VBA Macro to Number Rows

If the built-in Excel options don’t meet your needs, you can create a custom VBA macro to number rows however you like.

Some examples of advanced numbering:

  • Group rows into numbered sections
  • Restart sequence every X rows
  • Apply complex logic
  • Alternate row colors

Writing macros isn’t for everyone. But the flexibility can be useful for complex numbering schemes.


  1. Tap Alt + F11 to open the VBA Editor
  2. Insert a new module
  3. Write your numbering code
  4. Run macro to number rows

Here is an example macro that numbers rows in groups of 5:

Sub NumberRows()

    Dim LastRow As Long
    Dim RowCounter As Long
    Dim GroupNumber As Long

    LastRow = Range("A" & Rows.Count).End(xlUp).Row
    GroupNumber = 1

    For RowCounter = 1 To LastRow 
        If RowCounter Mod 5 = 1 Then GroupNumber = GroupNumber + 1
        Cells(RowCounter, "A").Value = GroupNumber
    Next RowCounter

End Sub

This provides the flexibility to create any numbering pattern imaginable.

Tips for Numbering Excel Rows

Here are some best practices when numbering rows in Excel:

  • Start numbering in first data row, not header
  • Use relative column references in formulas
  • Begin with Row 1 to easily add/remove rows
  • Name your tables using the “Table Name” field
  • Add a header row to make tables more readable
  • Use structured table references for dynamic ranges

Next Steps

Assigning row numbers provides many advantages when analyzing datasets in Excel. But it’s just one piece of better table management.

Here are some suggestions for leveling up your Excel table skills:

By mastering tables in Excel, you can get far more utility and productivity from your dashboards, models, and data analysis.