Use COUNTIF to Search a Range and Return a Result in Excel
Question details
Search a two-dimensional Excel range for a value and return one result if it appears and another if it does not.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user wants to check whether the word Blocking appears anywhere in cells A5:D9, including when it occurs more than once.
- Observed behavior
- The desired result is 20 when Blocking appears at least once and 10 when it does not.
Identify the range to search and the value to match. Select an empty cell outside that range for the result.
Return a result based on a COUNTIF match
Use IF with COUNTIF to return 20 when at least one cell matches and 10 when none do.
In Excel, click an empty cell outside A5:D9.
Type =IF(COUNTIF(A5:D9,"Blocking")>0,20,10) in the cell or formula bar.
Press Enter. Excel returns 20 if Blocking appears at least once in A5:D9; otherwise, it returns 10.

Count how many cells match the value
Use COUNTIF alone when you need the number of matching cells rather than a conditional result.
Search a Range with COUNTIF in WPS Spreadsheet
Use the same IF and COUNTIF formula in WPS Spreadsheet to check a range and return a result based on whether a value appears.
- 1. Open the spreadsheet: Open WPS Spreadsheet and use Open to select your workbook.
- 2. Select an empty cell: Click a cell outside the range you want to search.
- 3. Enter the formula: Type =IF(COUNTIF(A5:D9,"Blocking")>0,20,10), adjusting the range and values as needed.
- 4. Calculate and save: Press Enter to display the result, then use File > Save to save the workbook.

Frequently Asked Questions
Does the formula work if Blocking appears more than once?
Yes. COUNTIF counts all matching cells in A5:D9, and the IF formula returns 20 whenever that count is greater than zero.
Can I use a cell as the search value?
Yes. If the search value is in F1, enter =IF(COUNTIF(A5:D9,F1)>0,20,10) in the result cell.
Does COUNTIF distinguish between uppercase and lowercase?
No. COUNTIF treats text matches as case-insensitive, so Blocking and BLOCKING are counted as matches.
How do I match cells that contain Blocking within longer text?
Use wildcards around the word: =COUNTIF(A5:D9,"*Blocking*"). This counts cells containing Blocking anywhere in their text.




