Excel Formula to Return Y or N When a Value Matches Options
Question details
Check whether a manually entered value matches any of three option cells and return Y or N.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user enters a result and wants to compare it with three options in the same row.
- Observed behavior
- The formula should return Y when the entered result matches an option and N when it does not.
Identify the cells containing the three options and the entered result. The example below uses D4:F4 for the options, G4 for the result, and H4 for the formula.
Use COUNTIF to Return Y or N for a Matching Value
Use this formula to check whether the value in G4 matches any option in D4:F4.
Click H4, or another empty cell where you want the Y or N result to appear.
Type =IF(COUNTIF(D4:F4,G4)>0,"Y","N") in the formula bar and press Enter.
Select H4 and drag its fill handle down to copy the formula to additional rows. The references adjust for each row.

Check Matching Options in WPS Spreadsheet
Use the same IF and COUNTIF formula in WPS Spreadsheet to return Y or N for an entered value.
- 1. Open your spreadsheet: Open WPS Spreadsheet and choose Open to select your workbook.
- 2. Select an empty cell: Click H4, assuming your options are in D4:F4 and your entered value is in G4.
- 3. Enter the formula: Type =IF(COUNTIF(D4:F4,G4)>0,"Y","N") in the formula bar and press Enter.
- 4. Fill down: Drag the fill handle from H4 down to apply the formula to the remaining rows.

Frequently Asked Questions
How can I keep the result blank until a value is entered?
In H4, use =IF(G4="","",IF(COUNTIF(D4:F4,G4)>0,"Y","N")). This leaves H4 blank when G4 is empty.
Does COUNTIF distinguish between uppercase and lowercase letters?
No. COUNTIF comparisons are not case-sensitive, so an entry such as Yes matches an option written as YES.
Can I check more than three options?
Yes. Expand the range in the formula. For example, use =IF(COUNTIF(D4:H4,I4)>0,"Y","N") to check I4 against five options in D4:H4.
What happens when I copy the formula down?
The relative references change to match each row. For example, the formula copied from H4 to H5 checks G5 against D5:F5.




