Sort an Excel Source Worksheet Without Breaking Formulas
Question details
Sort records on an Excel source worksheet while keeping formulas on another worksheet linked to the correct records.

- 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.
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.
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.
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.
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.
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.
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.

Use an Excel Table With ID-Based Structured References
Use a table to keep related source rows together and make lookup ranges easier to maintain as records are added.
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. Open the workbook: Open WPS Spreadsheet and use Open to select your Excel workbook.
- 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. 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. 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.

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.




