Function Problems

Return Excel Values by Matching Names and a Column Q Condition

John WilsonJohn Wilson Dec 2, 2026 869 views

Question details

Return a corresponding value for each name based on whether its matching row has 1 in column Q.

Return Excel Values by Matching Names and a Column Q Condition
Product
Microsoft Excel
Device & OS
not provided
Scenario
Names in column B must be matched against lookup tables, with the result taken from column P when the matching column Q value is 1, or from column L otherwise.
Observed behavior
Each name should receive its corresponding lookup value, such as 50, or remain blank if the relevant lookup finds no match.
Before you start

Check that the names to look up are in B6:B15, the first lookup table uses O5:Q8, and the fallback table uses K5:L8. Make sure the condition in column Q is the numeric value 1, and adjust the ranges if your data is elsewhere.

Solution 1Recommended

Use XLOOKUP to return a value based on the column Q condition

Use this formula in an Excel version that supports XLOOKUP to select a value from column P or L for each name.

1
Enter the formula

Select C6 and enter =IF(B6="","",IF(XLOOKUP(B6,$O$5:$O$8,$Q$5:$Q$8,"")=1,XLOOKUP(B6,$O$5:$O$8,$P$5:$P$8),XLOOKUP(B6,$K$5:$K$8,$L$5:$L$8,""))).

2
Fill the formula down

Select C6 and drag its fill handle down through C15 to apply the lookup to each name in column B.

3
Check the results

Compare the results in column C with the matching rows in O5:Q8 and K5:L8. If Q is 1, the formula returns P; otherwise, it looks for the name in K and returns L.

Use XLOOKUP to return a value based on the column Q condition
Lookup behavior: XLOOKUP uses the first matching name. Blank input cells remain blank, and the fallback lookup returns blank when it cannot find the name in column K.
WPS Spreadsheets

Match names and return conditional values in WPS Spreadsheets

Open your workbook in WPS Spreadsheets and use INDEX and MATCH to check column Q and return the corresponding value from column P or L.

  1. 1. Open the workbook: Open WPS Spreadsheets and use Open to select your Excel workbook.
  2. 2. Enter the lookup formula: Select C6 and enter =IF(B6="","",IF(IFERROR(INDEX($Q$5:$Q$8,MATCH(B6,$O$5:$O$8,0)),"")=1,IFERROR(INDEX($P$5:$P$8,MATCH(B6,$O$5:$O$8,0)),""),IFERROR(INDEX($L$5:$L$8,MATCH(B6,$K$5:$K$8,0)),""))).
  3. 3. Apply it to the other names: Drag the fill handle from C6 through C15 and verify the results against your lookup tables.
  4. 4. Save the workbook: Choose Menu > Save As and select the Excel XLSX format if you need to share the workbook with Excel users.
Match names and apply the column Q condition with a formulaOpen and save Microsoft Excel XLSX workbooksFill a formula down a column for multiple namesUse familiar spreadsheet menus and cell references
QA img-9

Frequently Asked Questions

What happens if a name is missing from column O?

The formula checks the fallback table in K5:L8. If the name is found in column K, it returns the corresponding value from column L; otherwise, it returns a blank.

Why does the formula return a value from column L instead of P?

The formula uses column P only when the first matching name in O5:O8 has the numeric value 1 in column Q. Otherwise, it looks up the name in column K and returns the value from L.

What if the same name appears more than once?

XLOOKUP and MATCH use the first matching name in their respective lookup ranges. Review O5:O8 and K5:K8 for duplicates if the result is unexpected.

Can I use the formula without XLOOKUP?

Yes. Enter the INDEX and MATCH alternative in C6 and fill it down. It performs the same conditional lookup without XLOOKUP.