Function Problems

Use COUNTIF to Search a Range and Return a Result in Excel

Anum MushtaqAnum Mushtaq Dec 2, 2026 869 views

Question details

Search a two-dimensional Excel range for a value and return one result if it appears and another if it does not.

Use COUNTIF to Search a Range and Return a Result in Excel
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.
Before you start

Identify the range to search and the value to match. Select an empty cell outside that range for the result.

Solution 1Recommended

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.

1
Select the result cell

In Excel, click an empty cell outside A5:D9.

2
Enter the formula

Type =IF(COUNTIF(A5:D9,"Blocking")>0,20,10) in the cell or formula bar.

3
Confirm the result

Press Enter. Excel returns 20 if Blocking appears at least once in A5:D9; otherwise, it returns 10.

Return a result based on a COUNTIF match
Adjust the formula: Replace A5:D9, "Blocking", 20, and 10 with your own range, search value, and results. COUNTIF is not case-sensitive.
Work with formulas in WPS Office

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. 1. Open the spreadsheet: Open WPS Spreadsheet and use Open to select your workbook.
  2. 2. Select an empty cell: Click a cell outside the range you want to search.
  3. 3. Enter the formula: Type =IF(COUNTIF(A5:D9,"Blocking")>0,20,10), adjusting the range and values as needed.
  4. 4. Calculate and save: Press Enter to display the result, then use File > Save to save the workbook.
Search a two-dimensional range with COUNTIFReturn custom results with an IF formulaOpen and edit Microsoft Excel XLSX and XLS filesWork with formulas in a familiar spreadsheet interface
microsoft office alternative - wps office

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.