How to Use COUNTIF with Multiple Ranges in Google Sheets
To use COUNTIF with multiple ranges in Google Sheets, you can either use separate COUNTIF functions and add them together or use the COUNTIFS function. Here's how to do both:
Using separate COUNTIF functions:
- Open your Google Sheet.
- In an empty cell, type the formula
=COUNTIF(range1, criterion) + COUNTIF(range2, criterion)
.- Replace
range1
andrange2
with the ranges you want to apply the COUNTIF function to. - Replace
criterion
with the condition you want to count.
- Replace
- Press Enter.
For example, if you want to count the number of cells in the ranges A1:A5 and B1:B5 that contain the value "Yes", the formula would look like this:
=COUNTIF(A1:A5, "Yes") + COUNTIF(B1:B5, "Yes")
Using COUNTIFS function:
- Open your Google Sheet.
- In an empty cell, type the formula
=COUNTIFS(range1, criterion, range2, criterion)
.- Replace
range1
andrange2
with the ranges you want to apply the COUNTIFS function to. - Replace
criterion
with the condition you want to count.
- Replace
- Press Enter.
For example, if you want to count the number of cells in the ranges A1:A5 that contain the value "Yes" and B1:B5 that contain the value "No", the formula would look like this:
=COUNTIFS(A1:A5, "Yes", B1:B5, "No")
Keep in mind that the COUNTIFS function counts the number of cells that meet all the criteria, not just one.
Example
Let's say you have the following data in your Google Sheet:
A B
1 Yes No
2 No No
3 Yes Yes
4 No Yes
5 Yes No
To count the number of cells containing "Yes" in column A and "No" in column B, you can use the following formula:
=COUNTIF(A1:A5, "Yes") + COUNTIF(B1:B5, "No")
The result will be 5, as there are 3 "Yes" values in column A and 2 "No" values in column B.