Look up records across multiple sheets with automatic fallback

Write a multi-sheet lookup formula that searches a primary sheet and falls back to secondary sheets when an item is missing.

Text prompt for ChatGPT and Claude

You get: Modern Formula, legacy Formula and how the Fallback Logic Works

Prompt

Prompt
You are an enterprise spreadsheet expert. Create a lookup formula that searches a record across multiple worksheets sequentially until a match is found.

- Provide a modern Excel solution using XLOOKUP and IFERROR or nested XLOOKUPs.
- Provide an older Excel fallback using INDEX/MATCH with IFERROR.
- Include exact handling for cases where the record is absent from all sheets.
- Ensure ranges are absolute so formulas copy down without breaking.

Output format:
1. Modern Formula (Excel 365 / 2021)
2. Legacy Formula (Excel 2019 and older)
3. How the Fallback Logic Works
4. Setup Checklist

Here are my sheet names, lookup column, and return column details:

Example output

Lookup fallback order across three sheetsEach sheet is checked only if the previous one has no match
  1. Search CurrentStockFirstA match returns the value and stops
  2. Fall back to WarehouseBSecondUsed when CurrentStock returns #N/A
  3. Fall back to DiscontinuedThirdUsed when WarehouseB also fails
  4. Return Not FoundLastShown instead of an error if all three fail

Example for: searching Part ID in Sheet 'CurrentStock', falling back to 'WarehouseB', then 'Discontinued'

  1. Modern Formula (Excel 365 / 2021)
    =XLOOKUP(A2, CurrentStock!$A:$A, CurrentStock!$C:$C, XLOOKUP(A2, WarehouseB!$A:$A, WarehouseB!$C:$C, XLOOKUP(A2, Discontinued!$A:$A, Discontinued!$C:$C, "Not Found")))
  2. Legacy Formula (Excel 2019 and older)
    =IFERROR(INDEX(CurrentStock!$C:$C, MATCH(A2, CurrentStock!$A:$A, 0)), IFERROR(INDEX(WarehouseB!$C:$C, MATCH(A2, WarehouseB!$A:$A, 0)), IFERROR(INDEX(Discontinued!$C:$C, MATCH(A2, Discontinued!$A:$A, 0)), "Not Found")))
  3. How the Fallback Logic Works
  • The formula evaluates the CurrentStock sheet first.
  • If a match exists, it returns the value immediately and stops evaluating.
  • If CurrentStock returns #N/A, the formula passes control to the second lookup on WarehouseB.
  • If both fail, it queries Discontinued. If all three fail, it cleanly outputs "Not Found" instead of an error.
  1. Setup Checklist
  • Confirm lookup IDs are stored in the same format across all sheets (text vs. number).
  • Lock all sheet references with dollar signs before filling down.
  • Verify tab names match exactly, including spaces.
Written by AI from this prompt. Your results will vary.

Paste your sheet names and column layouts into ChatGPT, Claude, or Gemini after the prompt. If you have more than two fallback sheets, ask the model to adjust the formula using VSTACK or LAMBDA.

Reuse it: Use in a workflowTurn into a skillAdapt in the builder

Excel & Spreadsheets

Pick XLOOKUP, VLOOKUP or INDEX MATCH and Get the Exact Formula

You get one recommended lookup method for your Excel version and data layout, a paste-ready formula, and clear handling for values that have no match.

Excel & Spreadsheets

Compare spreadsheet columns and highlight missing items

Generates straightforward formulas to match two lists, spot missing entries like unpaid invoices, and flag discrepancies instantly.

Excel & Spreadsheets

Write an Excel or Google Sheets Formula from Plain English

Get a ready-to-paste Excel or Google Sheets formula built for your version and columns, with a step-by-step walkthrough and one test case to check it.

Excel & Spreadsheets

Build a 3D sum formula across multiple monthly tabs

Create a reliable 3D formula to aggregate identical cell references across multiple monthly worksheets into a single summary sheet.

Excel & Spreadsheets

Fix divide-by-zero errors in Excel variance formulas

Eliminate #DIV/0! errors in budget variance calculations with clean, professional handling for zero or missing values.

Excel & Spreadsheets

Highlight matching values across two separate spreadsheet columns

Generate the exact conditional formatting formula and click-by-click instructions to mark duplicate values found across two columns.