Function Problems

How to Generate Order Numbers Ignoring Blank Rows in Excel

Khadija KhanKhadija Khan Nov 11, 2026 869 views

Question details

The user needs to generate sequential order numbers in a spreadsheet, ensuring that blank rows are ignored and do not disrupt the numbering sequence.

How to Generate Order Numbers Ignoring Blank Rows in Excel
Product
Excel
Device & OS
not provided
Scenario
Organizing order lists with multiple item rows and empty rows where a continuous order ID needs to be assigned without incrementing on blank spaces.
Observed behavior
Order numbers like 24-0001 and 24-0002 should correctly display on the first row of each new order, and any blank rows must not alter the overall sequence.
Before you start

Ensure your version of Excel supports dynamic array functions (such as Microsoft 365 or the latest WPS Office), as the most efficient solution requires the LET, SCAN, and HSTACK functions.

Solution 1Recommended

Use Dynamic Array Functions (LET and SCAN) in Excel 365

Utilize modern dynamic array functions to systematically count new orders and item positions while completely skipping blank rows.

By utilizing the LET function, you can define variables within your formula to compare each row with the previous one. The SCAN function then iterates through these arrays to increment your order numbers only when a new, non-blank order is detected.

1
Select the target cell

Click on the first cell of the column where you want the sequence of order numbers to begin.

2
Enter the dynamic LET formula

Input the following formula into the formula bar: =LET(priorOrder, DROP(VSTACK("", order), -1), newOrder, order<>priorOrder, orderNum, SCAN(0, newOrder, LAMBDA(acc, new, IF(new, acc+1, acc))), itemNumber, SCAN(0, newOrder, LAMBDA(acc, new, IF(new, 1, acc+1))), HSTACK(orderNum, itemNumber))

3
Adjust the defined names

Replace the word 'order' in the formula with the actual cell range of your source data (for example, A2:A100) to ensure the blank-row logic correctly matches your dataset.

4
Apply the formula

Press the Enter key. The formula will automatically spill down the column, generating accurate order sequence numbers and item numbers within each order.

Use Dynamic Array Functions (LET and SCAN) in Excel 365
Compatibility Note: The SCAN and HSTACK functions are only available in Microsoft 365, Office 2021, or newer spreadsheet versions supporting dynamic arrays.
Efficient Data Processing

Easily Manage Advanced Array Formulas with WPS Spreadsheet

WPS Spreadsheet provides robust support for advanced dynamic array functions, making it simple to process complex datasets and generate sequential order numbers effortlessly.

  1. 1. Open your dataset in WPS Spreadsheet: Launch WPS Office, select Spreadsheet, and open your workbook containing the order list.
  2. 2. Apply the array formula: Select the target cell, paste the LET and SCAN formula to generate the sequence, and press Enter.
  3. 3. Save your document: Press Ctrl+S to save your work. The document remains fully compatible with standard .xlsx formats.
Fully compatible with Microsoft Excel formulas and file formats (.xlsx).Supports advanced dynamic array functions like LET, SCAN, and VSTACK out of the box.Free, lightweight, and ensures smooth performance even with large datasets.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my formula return a #NAME? error?

A #NAME? error usually occurs if your version of Excel does not support dynamic array functions like LET, SCAN, or HSTACK. You will need Microsoft 365, Office 2021, or the latest version of WPS Office to use these advanced functions.

Can I customize the order number format to include text, like '24-0001'?

Yes. You can modify the formula by wrapping the final 'orderNum' output in a TEXT function. For example, replacing 'orderNum' in the HSTACK portion with '"24-"&TEXT(orderNum, "0000")' will format your output exactly as '24-0001'.

Will this formula automatically update if I insert a new row?

Because dynamic array formulas automatically spill into adjacent empty cells, the results will update. However, if you insert a row directly into the middle of your source range, ensure your 'order' range reference covers the new row, or format your source data as an official Excel Table.