you can type the function =COUNTIF(A1:J1, 5) in cell A3, where it produces the result 2, that being the number of cells in the range A1:J1 with the value 5.
1 6 5 1 5 2 1 8 4 7
However, if you want to count the number of cells whose values are either 5 or 1, the COUNTIF() function is not appropriate because it does not recognize compound criteria such as "5 OR 1." For that purpose, you need to use SUM(IF()) as an array function.
To obtain this result for the preceding data, follow these steps:
- Start Microsoft Excel with a new worksheet.
- Type the values listed earlier in this section in cells A1:J1 of the worksheet.
- In cell A3, type the following function =SUM(IF((A1:J1=5)+(A1:J1=1), 1, 0))and then press CTRL+SHIFT+ENTER simultaneously to enter the array formula.