Function Problems

How to Generate Automatic Serial Numbers Based on an Adjacent Excel Column

Khadija KhanKhadija Khan Oct 26, 2026 869 views

Question details

The user wants to automatically generate sequential serial numbers in column A based on the populated rows in column B, which updates dynamically from drop-down selections and array formulas.

Generate Automatic Serial Numbers Based on an Adjacent Excel Column
Product
Spreadsheet
Device & OS
not provided
Scenario
Creating a dynamic numbered list that automatically expands or contracts when the adjacent source data changes.
Observed behavior
The user needs a formula setup that dynamically detects the variable number of non-empty rows in column B and populates the exact corresponding amount of serial numbers in column A.
Before you start

Determine whether your adjacent data column is populated using a modern spilled dynamic array formula or standard individual cell data, as this dictates the best formula to use.

Solution 1Recommended

Use Dynamic Array Formulas (SEQUENCE)

This is the most efficient method if your adjacent column contains a spilled dynamic array formula.

By utilizing the SEQUENCE function combined with an IF statement, your serial numbers will automatically spill down the exact number of rows as the target array. The '#' symbol refers to the entire spilled array range starting from the referenced cell.

1
Select the target cell

Click on cell A2, or whichever cell you want your serial numbers to start in.

2
Enter the dynamic formula

Type the formula `=IF(B2#<>"",SEQUENCE(ROWS(B2#)),"")` into the formula bar. Replace 'B2' with the starting cell of your adjacent dynamic array.

3
Apply the array

Press Enter. The serial numbers will automatically populate and expand or contract whenever the drop-down selection changes the array size in column B.

Use Dynamic Array Formulas (SEQUENCE)
Spilled Array Requirement: This method requires your source data in column B to be a dynamic spilled array. If it is standard data, use the COUNTIF method instead.
Smart Spreadsheet Solution

Auto-Number Dynamic Rows Easily with WPS Spreadsheet

WPS Spreadsheet fully supports advanced dynamic arrays and functions like SEQUENCE, allowing you to create auto-adjusting serial numbers seamlessly while maintaining complete compatibility with your existing Excel files.

  1. 1. Open your file in WPS: Launch WPS Spreadsheet and open your workbook containing the dynamic drop-down lists.
  2. 2. Select the serial number column: Click the first cell in column A where the numbering should begin.
  3. 3. Insert the dynamic formula: Type `=IF(B2#<>"",SEQUENCE(ROWS(B2#)),"")` and press Enter.
  4. 4. Watch the data update automatically: Change your drop-down selection to verify that the serial numbers adjust perfectly to match the number of populated rows in column B.
Fully compatible with Microsoft Excel formulas (.xlsx format)Supports modern dynamic array functions like SEQUENCE and FILTERLightweight, fast-loading, and free to useIntuitive tabbed interface for managing multiple workbooks
microsoft office alternative - wps office

Frequently Asked Questions

Why is my SEQUENCE formula returning a #NAME? error?

A #NAME? error usually means your version of Excel or your spreadsheet software does not support dynamic array functions like SEQUENCE. If this happens, use the alternative `=IF(B2<>"",COUNTIF($B$2:B2,"<>"),"")` formula method instead.

How can I handle blank rows in the middle of my data?

If your data in column B contains blank rows but you want the serial numbers to continue sequentially without skipping numbers, the COUNTIF method `=IF(B2<>"",COUNTIF($B$2:B2,"<>"),"")` works perfectly, as it only increments the count when it encounters non-blank cells.

What does the '#' symbol mean in the formula?

The '#' symbol is the spilled range operator. When placed after a cell reference (like B2#), it tells the spreadsheet software to reference the entire dynamic array range that originates from that cell, rather than just the single cell.