Excel IF Formula to Return an Error for Multiple Yes Values
Question details
Find a formula that checks four cells for Yes and returns a corresponding value only when exactly one cell matches.

- 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.
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.
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.
Click an empty cell where you want the result to appear.
Type =IF(COUNTIF(B2:B5,"Yes")>1,"ERROR",IFERROR(XLOOKUP("Yes",B2:B5,D2:D5,""),"")) and press Enter.
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 with INDEX and MATCH in older Excel versions
Use this alternative if your Excel version supports IFERROR but does not include XLOOKUP.
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. Open your spreadsheet: Open WPS Office, choose Spreadsheet, and open your workbook or create a new sheet.
- 2. Arrange the data: Enter the four conditions in B2:B5 and their corresponding results in D2:D5.
- 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. Verify the output: Change the Yes entries in B2:B5 to test the single-match, multiple-match, and no-match cases.

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.




