Others

Create a Large Custom Sort Order in Excel

Maira MehtabMaira Mehtab Nov 25, 2026 869 views

Question details

Create an Excel sort order based on a sequence of 28,608 values without using a custom list.

Create a Large Custom Sort Order in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
The user needs to sort a data table according to a large, predefined sequence.
Observed behavior
Excel custom lists have practical size limits that make them unsuitable for the 28,608-row sequence.
Before you start

Place the desired sort values in their exact order on a separate worksheet, with a header above the list. Check that each lookup value is unique and matches the corresponding value in the main data.

Solution 1Recommended

Sort by a VLOOKUP sequence number

Use a lookup table and helper column to apply a custom order that is too large for an Excel custom list.

The lookup table assigns a numeric position to each value. Sorting the main data by that position reproduces the desired sequence.

1
Create the lookup table

On Sheet2, put the ordered values in A2:A28609. Enter 1 in B2 and 2 in B3, select both cells, and drag the fill handle down to B28609 to number the sequence.

2
Add a helper column

In the main data sheet, add a column named Sort Order. If the value to match is in A2, enter =VLOOKUP(A2,Sheet2!$A$2:$B$28609,2,FALSE) in the helper column's first data row. Adjust the cell and sheet references to match your workbook.

3
Fill and check the formula

Drag or double-click the helper cell's fill handle to copy the formula down. Check for #N/A results and correct values that are missing from or do not match the lookup table.

4
Sort the complete table

Select the entire data table, including headers, then choose Data > Sort. Select Sort Order as the sort column, choose Smallest to Largest, and confirm the sort.

Sort by a VLOOKUP sequence number
Repeated values: Rows with the same lookup value receive the same sequence number. Add a secondary sort key if those rows need a specific order.
Sort large sequences with WPS Spreadsheets

Apply a Large Custom Sort Order in WPS Spreadsheets

Use a lookup table and VLOOKUP helper column in WPS Spreadsheets to sort an Excel workbook by a long predefined sequence.

  1. 1. Open the workbook: Open WPS Spreadsheets and use File > Open to select the Excel workbook.
  2. 2. Build the sequence table: On a separate sheet, enter the desired values in column A and their ascending sequence numbers in column B.
  3. 3. Calculate sort positions: Add a Sort Order column to the main table. Enter a formula such as =VLOOKUP(A2,Sheet2!$A$2:$B$28609,2,FALSE), adjust the references, and fill it down.
  4. 4. Sort and save: Select the entire table, choose Data > Sort, and sort the Sort Order column from smallest to largest. Use File > Save As to save the result.
Sort by a sequence stored in worksheet cellsUse VLOOKUP to assign numeric sort positionsOpen and edit Microsoft Excel XLSX filesKeep related rows together when sorting the full table
microsoft office alternative - wps office

Frequently Asked Questions

Why does the VLOOKUP formula return #N/A?

The value may be missing from the lookup table or may not match because of spaces or a text-versus-number difference. Check the value in the main table against column A of the lookup sheet.

What happens if a value appears more than once in the lookup list?

VLOOKUP returns the sequence number for the first match. Make each lookup value unique if it should have one unambiguous sort position.

Can I sort only the helper column?

Select the entire data table before choosing Data > Sort. Sorting only the helper column can separate its values from the corresponding rows.

How do I order rows that have the same custom sort value?

In Data > Sort, add a secondary sort level, such as a date or original row number, after the Sort Order column.