Excel Formula to Check Multiple Noncontiguous Cells for 1
Question details
Check whether all records matching a specified value contain 1 and return a numeric result.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- Matching records may appear in noncontiguous rows, with identifiers in column C and values to test in column D.
- Observed behavior
- The desired result is 1 when every matching record contains 1, or 0 when any matching value differs from 1.
Confirm that C2:C24 contains the record identifiers, D2:D24 contains the values to check, and F8 contains the identifier to find. Adjust both ranges together if your data covers different rows.
Compare matching records with COUNTIF and COUNTIFS
Use this formula when the relevant rows share an identifier but are scattered throughout the table.
COUNTIF counts all records matching F8, while COUNTIFS counts those matching records whose value in column D is 1. N converts the comparison to a numeric 1 or 0.
In your Excel worksheet, click an empty cell where you want the result to appear.
Type =N(COUNTIF($C$2:$C$24,F8)=COUNTIFS($C$2:$C$24,F8,$D$2:$D$24,1)) and press Enter.
Look at the result cell: 1 means every matching value is 1; 0 means at least one matching value is not 1. Change F8 or copy the formula down to check another identifier.

Check scattered records with WPS Spreadsheets
Use the same COUNTIF and COUNTIFS formula in WPS Spreadsheets to test all rows matching an identifier and return 1 or 0.
- 1. Open the workbook: Launch WPS Spreadsheets and use Open to select your Excel workbook.
- 2. Check the columns: Locate the identifiers in C2:C24, the values in D2:D24, and the identifier to test in F8; adjust the references if your layout differs.
- 3. Enter the formula: Click an empty cell, enter =N(COUNTIF($C$2:$C$24,F8)=COUNTIFS($C$2:$C$24,F8,$D$2:$D$24,1)), and press Enter.
- 4. Review and save: Check the result cell for 1 or 0, then use File > Save to save your changes.

Frequently Asked Questions
What happens if a matching cell is blank or contains a value other than 1?
That record is counted by COUNTIF but not by COUNTIFS with the criterion 1, so the formula returns 0.
Why does the formula return 1 when there are no matching records?
Both counts are zero, so they are equal. Add a COUNTIF($C$2:$C$24,F8)>0 condition with AND if you want no matches to return 0.
Can I check a different identifier in each row?
Place the formula beside the first identifier and copy it down using the fill handle. The F8 reference changes by row, while the ranges marked with dollar signs remain fixed.
Do the matching records have to be in adjacent rows?
No. COUNTIF and COUNTIFS scan the specified ranges and include every row whose identifier matches F8, even when other records appear between them.




