How to Fix Excel INDEX/MATCH References That Break After Sorting
Question details
Resolve an issue where INDEX/MATCH formulas calculate incorrect results or fail to adjust properly after sorting the dataset.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Sorting a dataset that contains INDEX/MATCH formulas looking up data from a different worksheet.
- Observed behavior
- The formulas return wrong results or lose synchronization with their rows because the lookup reference includes the current sheet name and fails to adjust dynamically during a sort.
Before modifying your formulas, verify that you have correctly locked your lookup array references with absolute formatting (e.g., $A$3:$A$197) so the source data range does not shift unintentionally.
Remove Current Worksheet Name from Lookup References
By stripping out the current sheet name from the MATCH function's lookup value, Excel can dynamically adjust the reference during sorting.
When a formula references a cell on the same worksheet, adding the sheet name (e.g., 'Sheet1!B8') hardcodes the sheet context. During a sort operation, this can cause the reference to stick to the original row rather than moving with the sorted data.
Using a standard relative reference (e.g., 'B8') ensures the formula remains tied to the correct record in its current row after the sort is applied.
Click on the cell containing your broken INDEX/MATCH formula to view it in the formula bar.
Look at the MATCH function segment, specifically the first argument known as the lookup_value (e.g., MATCH(Sheet1!B8, ...)).
Delete the sheet name and the exclamation mark so only the relative cell reference remains (change it to MATCH(B8, ...)).
Press Enter to save the formula, then double-click the fill handle in the bottom-right corner of the cell to copy the updated formula down the entire column.

Replace Empty Text Strings with Zeros for Numeric Filtering
If you use an IFERROR wrapper with your INDEX/MATCH, returning an empty text string can break numeric filters.
Easily Manage Advanced Formulas with WPS Spreadsheet
WPS Office offers a powerful, intuitive Spreadsheet application that fully supports advanced functions like INDEX, MATCH, and XLOOKUP. It seamlessly handles sorting operations without breaking relative references.
- 1. Open your dataset: Launch WPS Spreadsheet and open your existing workbook containing the lookup tables.
- 2. Edit the formula: Double-click the target cell to enter formula editing mode and type your INDEX/MATCH formula.
- 3. Use relative references: Select the lookup value within the same sheet simply by clicking the cell, ensuring no sheet name is added (e.g., B8).
- 4. Sort the data: Highlight your table and use the built-in Sort tool under the Data tab to organize your records flawlessly.

Frequently Asked Questions
Why do absolute references break when sorting in Excel?
Absolute references (using $ signs, like $B$8) lock the formula to a specific physical cell address on the grid. When you sort rows, the formula stays pointed at the original address rather than following the data value that moved. Always use relative references (like B8) for lookup values in lists that will be sorted.
Should I use XLOOKUP instead of INDEX/MATCH?
XLOOKUP is a more modern, simplified function that combines the capabilities of INDEX and MATCH into a single formula. It is generally less prone to reference errors and is highly recommended if your spreadsheet software supports it.
How do I lock the lookup array but keep the lookup value dynamic?
Use absolute references with dollar signs for the lookup array (e.g., Sheet2!$A$3:$A$197) so the source table range doesn't shift when copied. Concurrently, use relative references without dollar signs for the lookup value (e.g., B8) so it adjusts dynamically as you copy it down or sort rows.




