Function Problems

Excel IF Formula to Return an Error for Multiple Yes Values

Nimra MalikNimra Malik Nov 18, 2026 869 views

Question details

Find a formula that checks four cells for Yes and returns a corresponding value only when exactly one cell matches.

Excel IF Formula to Return an Error for Multiple Yes Values
Product
Microsoft Excel
Device & OS
not provided
Scenario
Four cells contain conditions, and a second four-cell range contains their corresponding results.
Observed behavior
The desired formula should return the corresponding result for one Yes, display ERROR for two or more Yes values, and return a blank when there are no matches.
Before you start

Arrange the four conditions in B2:B5 and their corresponding results in D2:D5, with each condition and result on the same row. Adjust both ranges in the formula if your data is in different cells.

Solution 1Recommended

Use COUNTIF and XLOOKUP in a supported Excel version

Use this formula in Excel for Microsoft 365 or Excel 2021 and later to find the corresponding result and flag multiple Yes values.

1
Select an output cell

Click an empty cell where you want the result to appear.

2
Enter the formula

Type =IF(COUNTIF(B2:B5,"Yes")>1,"ERROR",IFERROR(XLOOKUP("Yes",B2:B5,D2:D5,""),"")) and press Enter.

3
Check the result

Enter Yes in one cell in B2:B5 to return the value from the same row in D2:D5. Enter Yes in two or more cells to display ERROR; remove all Yes values to return a blank.

Use COUNTIF and XLOOKUP in a supported Excel version
ERROR is text: The formula displays the word ERROR; it does not generate an Excel error value. IFERROR also converts errors from the lookup result to a blank.
WPS Spreadsheet formula

Check for Multiple Yes Values in WPS Spreadsheet

Use COUNTIF, INDEX, and MATCH in WPS Spreadsheet to return a corresponding value for one Yes or display ERROR when multiple cells contain Yes.

  1. 1. Open your spreadsheet: Open WPS Office, choose Spreadsheet, and open your workbook or create a new sheet.
  2. 2. Arrange the data: Enter the four conditions in B2:B5 and their corresponding results in D2:D5.
  3. 3. Enter the formula: Select an empty cell and enter =IF(COUNTIF(B2:B5,"Yes")>1,"ERROR",IFERROR(INDEX(D2:D5,MATCH("Yes",B2:B5,0)),"")), then press Enter.
  4. 4. Verify the output: Change the Yes entries in B2:B5 to test the single-match, multiple-match, and no-match cases.
Check four conditions and return the matching row's valueDisplay a clear message when multiple Yes values are presentOpen and edit Microsoft Excel XLSX filesUse familiar spreadsheet formulas and cell references
QA img-9

Frequently Asked Questions

What happens if none of the four cells contains Yes?

Both formulas return an empty string, so the output cell appears blank.

Does the formula distinguish between Yes and YES?

No. COUNTIF and an exact MATCH or XLOOKUP are not case-sensitive for this text. Extra spaces can prevent an entry from matching Yes.

Can I use different ranges for the conditions and results?

Yes. Replace B2:B5 with your condition range and D2:D5 with the corresponding result range. Keep the ranges the same size and align each condition with its result.

Why does the formula show the word ERROR instead of an Excel error?

The text "ERROR" is the value specified in the IF formula when COUNTIF finds more than one Yes. It is a message, not an error value such as #N/A.