How to Automatically Number Rows in Google Sheets Using the ROW Function

Maintaining accurate row numbering in large spreadsheets is essential for inventory records, customer lists, and transaction ledgers. Entering sequential numbers manually or dragging down fill handles works initially, but deleting rows or inserting new data creates broken sequences and duplicate numbers. By replacing static digits with dynamic formula numbering using the ROW function in Google Sheets, your sequence recalculates automatically whenever rows are added, moved, or deleted.

Basic ROW Function Syntax and Offset Calculation

The ROW function returns the physical spreadsheet row coordinate of a cell as an integer.

=ROW([cell_reference])

When used without arguments (e.g. =ROW()), it returns the row number of the current cell. Because spreadsheets typically feature column headers on Row 1, entering =ROW() on data row 2 outputs 2 instead of 1. To calibrate your numbering to start at 1, subtract the header offset:

=ROW() - 1

Enter =ROW()-1 into cell A2. As you drag or copy the formula down Column A, cell A3 outputs 2, A4 outputs 3, and so on. If you delete row 5, the remaining rows instantly adjust their displayed sequence without leaving gaps.

Conditional Numbering: Only Number Rows with Data

Dragging formulas into empty rows creates trailing numbers next to blank records. To display row numbers strictly when adjacent data exists (for example, when Customer Name in Column B is filled), wrap the function in an IF condition:

=IF(ISBLANK(B2), "", ROW() - 1)

If cell B2 has no data, the formula returns an empty string (""). The moment someone types an entry into Column B, the sequential index number appears automatically.

Automating Entire Columns with ARRAYFORMULA

Rather than copying formulas manually down thousands of rows, you can manage row numbering across an entire column with a single array formula placed in your header or first data cell:

=ARRAYFORMULA(IF(B2:B="", "", ROW(B2:B) - 1))

Place this single formula into cell A2. Google Sheets will automatically project sequential numbers down the entire column as new rows are typed into Column B, eliminating the need to drag or maintain helper formulas forever.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.