Excel Lookup: Skip Errors and Return the Next Available Week Value
Question details
Find a matching ID and return its first available week value while skipping rows with errors.

- 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.
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.
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.
Type the ID you want to find in cell D2.
Select an empty result cell and enter =XLOOKUP(1,(A2:A100=D2)*IFERROR(--(B2:B100<>""),0),B2:B100,"Not found").
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 INDEX and MATCH with a helper column
Use a helper column when XLOOKUP is unavailable or when you want to inspect which rows qualify.
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. Open the worksheet: Open your Excel file in WPS Spreadsheets and identify the ID and week-value columns.
- 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. Create a helper column: Enter =IFERROR(AND(A2=$D$2,B2<>""),FALSE) in C2 and fill it down to C100.
- 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.

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.




