Calculation Issues

Sort an Excel Source Worksheet Without Breaking Formulas

Steve KSteve K Dec 2, 2026 869 views

Question details

Sort records on an Excel source worksheet while keeping formulas on another worksheet linked to the correct records.

Sort an Excel Source Worksheet Without Breaking Formulas
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains source data that another worksheet uses in formulas, and the source records need to be sorted.
Observed behavior
After sorting, formulas should return values for the intended records rather than values based solely on their former row positions.
Before you start

Identify every column that belongs to each source record and choose a unique ID for each row. Check which formulas on the other worksheet currently refer to fixed source cells such as =SheetA!A2.

Solution 1Recommended

Sort Complete Rows and Look Up Records by Unique ID

Use this method when formulas must continue returning the same records after the source worksheet is reordered.

Sorting all related columns together keeps each record intact. A direct reference such as =SheetA!B2 can still point to a row position rather than the intended record, so use the record's unique ID in a lookup formula.

1
Add unique IDs

On the source worksheet, enter a distinct ID for each record in a column, such as column A. Put the corresponding IDs on the formula worksheet, for example in column A.

2
Replace row-based formulas

On the formula worksheet, enter =INDEX(SheetA!$B$2:$B$100,MATCH(A2,SheetA!$A$2:$A$100,0)) in B2. Replace SheetA and the ranges with your source sheet and columns, then fill the formula down.

3
Sort the complete source range

On SheetA, select the full data range, including the ID and all related columns. Choose Data > Sort, select the column and order, and confirm the sort.

4
Check the results

Return to the formula worksheet and compare several IDs and returned values with the sorted source data. An #N/A result indicates that MATCH could not find the ID.

Sort Complete Rows and Look Up Records by Unique ID
Keep lookup ranges current: Expand both lookup ranges when records are added beyond row 100, or use table references. IDs should be unique; MATCH returns the first match.
Work with spreadsheets in WPS Office

Sort Source Records and Preserve Lookups in WPS Spreadsheet

Use WPS Spreadsheet to sort complete source rows and retrieve values by unique ID, so formulas on another sheet can find the intended records after sorting.

  1. 1. Open the workbook: Open WPS Spreadsheet and use Open to select your Excel workbook.
  2. 2. Prepare record IDs: On the source sheet, give each record a unique ID in column A. On the formula sheet, enter the IDs you want to look up in column A.
  3. 3. Add the lookup formula: In B2 on the formula sheet, enter =INDEX(SheetA!$B$2:$B$100,MATCH(A2,SheetA!$A$2:$A$100,0)). Adjust the sheet name and ranges, then fill the formula down.
  4. 4. Sort and verify: Select all related columns on the source sheet and choose Data > Sort. After sorting, return to the formula sheet and check the IDs and returned values.
Keep related source columns together when sortingUse INDEX and MATCH to retrieve records by IDOpen and edit Microsoft Excel XLSX and XLS filesWork in a familiar, easy-to-use spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does my formula show a different record after I sort?

A formula such as =SheetA!B2 refers to a cell position, which may contain a different record after sorting. Use a unique ID with INDEX and MATCH to find the intended record.

Can I sort just one column of the source data?

Avoid sorting a single column when its values belong to records across multiple columns. Select the complete source range and use Data > Sort so related values move together.

Does converting the source range to a table fix every reference?

No. An Excel table helps keep rows together and supports structured references, but a lookup by unique ID is still needed when a formula must follow a particular record.

What does #N/A mean in the INDEX and MATCH formula?

It usually means MATCH could not find the requested ID in the source range. Check that the ID exists, that the lookup range includes it, and that the ID values use consistent formats.