Count Noncontiguous Ranges and Exclude Cells with COUNTIF
Question details
The user needs to count matching values across selected ranges while excluding other cells.

- Product
- WPS Spreadsheets
- Device & OS
- not provided
- Scenario
- Count values greater than or equal to 4 in B2:C2, E2:G2, and I2:J2 without including the cells between those ranges.
- Observed behavior
- A single continuous COUNTIF range would also include the unwanted cells unless additional logic is used.
Identify the ranges to include and confirm the criterion you want to count. In this example, D2 and H2 are excluded, and the criterion is greater than or equal to 4.
Add COUNTIF results for the included ranges
Use a separate COUNTIF for each included range and add the results to exclude the cells between them.
In WPS Spreadsheets, click an empty cell where you want the count to appear.
Type =COUNTIF(B2:C2,">=4")+COUNTIF(E2:G2,">=4")+COUNTIF(I2:J2,">=4") in the cell or formula bar.
Press Enter. The result counts matching values in the three specified ranges and leaves out D2 and H2.
Edit the cell ranges and the ">=4" criterion in the formula bar to match your worksheet.

Count a continuous range and subtract excluded cells
Use this approach when most cells in a continuous range should be included and only a few need to be excluded.
Count selected ranges in WPS Spreadsheets
Use COUNTIF formulas in WPS Spreadsheets to count matching values in separate ranges without including the cells between them.
- 1. Open the spreadsheet: Open WPS Spreadsheets and select File > Open to choose your workbook.
- 2. Choose an output cell: Click an empty cell where you want to display the count.
- 3. Enter the COUNTIF formula: Type =COUNTIF(B2:C2,">=4")+COUNTIF(E2:G2,">=4")+COUNTIF(I2:J2,">=4"), adjusting the ranges and criterion as needed.
- 4. Show the result: Press Enter to calculate the total for the included ranges.

Frequently Asked Questions
Can COUNTIF exclude individual cells from a continuous range?
Not directly within a single range argument. Add COUNTIF results for the included ranges, or subtract COUNTIF results for the excluded cells from the count of the full range.
How do I count values greater than 4 instead of at least 4?
Replace ">=4" with ">4" in each COUNTIF in the formula bar. This excludes values equal to 4.
What happens if my included ranges overlap?
Matching cells in the overlapping area are counted more than once when you add the COUNTIF results. Edit the ranges so each cell appears only once.
Can I use the same formulas in Microsoft Excel?
Yes. Excel supports COUNTIF and the addition or subtraction formulas shown here. Open the workbook in Excel and enter the formula in a worksheet cell.




