Formula Errors

Excel Lookup: Skip Errors and Return the Next Available Week Value

Kushani NimanthikaKushani Nimanthika Nov 20, 2026 869 views

Question details

Find a matching ID and return its first available week value while skipping rows with errors.

Make Excel Lookups Skip Errors and Return the Next Available Week Value
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains repeated IDs and week values, some of which contain errors or are blank.
Observed behavior
The user needs a lookup that continues past unavailable values instead of returning an error or an incorrect match.
Before you start

Identify the ID column, the week-value column, and the cell containing the ID to find. The examples use IDs in A2:A100, week values in B2:B100, and the lookup ID in D2; adjust the ranges to fit your sheet.

Solution 1Recommended

Use XLOOKUP to skip errors and blank week values

Use this formula in Excel versions that support XLOOKUP to return the first usable week value for an ID.

The formula checks for an exact ID match and excludes errors and blank week values. It returns the first qualifying value in worksheet order, whether the value is a number or text.

1
Enter the lookup ID

Type the ID you want to find in cell D2.

2
Enter the XLOOKUP formula

Select an empty result cell and enter =XLOOKUP(1,(A2:A100=D2)*IFERROR(--(B2:B100<>""),0),B2:B100,"Not found").

3
Check the ranges

Adjust A2:A100 and B2:B100 to cover the same rows of your data, then press Enter. Make sure the ID range itself does not contain errors.

Use XLOOKUP to skip errors and blank week values
Worksheet order matters: The result is the first valid matching row, not necessarily the earliest week. The formula skips actual Excel errors such as #N/A, not text that merely looks like an error.
WPS Spreadsheets

Find the next available week value in WPS Spreadsheets

Use a helper column with INDEX and MATCH in WPS Spreadsheets to find the first error-free, nonblank week value for an ID.

  1. 1. Open the worksheet: Open your Excel file in WPS Spreadsheets and identify the ID and week-value columns.
  2. 2. Enter the ID: Using the example layout, type the lookup ID in D2, with IDs in A2:A100 and week values in B2:B100.
  3. 3. Create a helper column: Enter =IFERROR(AND(A2=$D$2,B2<>""),FALSE) in C2 and fill it down to C100.
  4. 4. Find the first valid value: In an empty cell, enter =IFERROR(INDEX(B2:B100,MATCH(TRUE,C2:C100,0)),"Not found"). Adjust the ranges if your data uses different rows.
Skip error and blank week values in lookup resultsWorks with Microsoft Excel XLS and XLSX filesInspect matching rows in a visible helper columnUse familiar spreadsheet formulas and controls
microsoft office alternative - wps office

Frequently Asked Questions

Will these formulas work if the data is unsorted?

Yes. Both methods check for an exact ID match and return the first qualifying row in worksheet order; they do not require sorting.

Can the lookup return a text value such as Wk3?

Yes. Both formulas accept text or numeric week values, provided the cell is not blank and does not contain an actual Excel error.

What happens if every matching week value is blank or an error?

The formulas return "Not found" when no matching row has a usable week value. You can replace that text in the formula with another message.

Does the result represent the earliest week?

Not necessarily. The formulas return the first valid match from top to bottom. Sort the rows by week first if worksheet order should determine the earliest result.