If you want to compare two ranges, and count total matches between the two ranges, you can use a formula that combines the COUNTIF and SUMPRODUCT functions.
Context
Suppose you have a "master" list of some kind, and...

One way to track attendance is with simple formulas based on the COUNTIF function. In the example shown, the formula in M5 is:
=COUNTIF(C5:L5,"x")
How this formula works
This formula simply uses COUNTIF...

Excel contains a built-in preset for highlighting duplicate values with conditional formatting, but it only works at the cell level. If you want to highlight entire rows that are duplicates you'll need to use your own...

To track student class enrollment when classes may appear in any order, you can create a table with additional columns, one for each class, to mark and count enrollment. In the example shown, the formula in G6 is:
=...

Excel contains a built-in preset for highlighting duplicate values with conditional formatting, but it only works at the cell level. If you want to find and highlight duplicate columns, you'll need to use your own...

Note: Excel contains many built-in "presets" for highlighting values with conditional formatting, including a preset to highlight duplicate values. However, if you want more flexibility, you can highlight duplicates...

To count of cells that are not blank in a range, you can use the COUNTA function. In the example shown, E5 contains this formula:
=COUNTA(B5:B9)
How this formula works
COUNTA is fully automatic. When given a range...

To subtotal values by invoice number, you can use a formula based on COUNTIF and SUMIF. In the example shown, the formula in E5 is:
=IF(COUNTIF($B$5:B5,B5)=1,SUMIF($B:$B,B5,$D:$D),"")
How this formula works...

To search an entire worksheet for a value and return a count, you can use a formula based on the COUNTIF function.
In the example shown, the formula in C5 is:
=COUNTIF(Sheet2!1:1048576,C4)
How this formula works...

To count cells that contain either one value or another, you an either use a helper column then tally up the count, or a more complex single cell formula.
Background
When you count cells with "OR" criteria, you need...

To use count a non-contiguous range with criteria, you can use the COUNTIF function together with INDIRECT and SUM. In the example shown, cell I5 contains this formula:
=SUM(COUNTIF(INDIRECT({"B5:B8","...

To search multiple worksheets in a workbook for a value and return a count, you can use a formula based on the COUNTIF and INDIRECT functions. With some setup, you use this approach to search an entire workbook for a...

To count the number of unique or distinct values in a range of cells (named "data" in the example below), you can use a formula based on the COUNTIF and SUMPRODUCT functions.
How the formula works
Working from the...

To dynamically sort text values in alphabetical order, you can use use a formula based on the COUNTIF function. In the example shown, the formula in C5 is:
=COUNTIF(countries,"<="&B5)
where "...

To create a running count of certain values that appear in range of cells, you can use the COUNTIF with a "mixed reference" to create a running total. In the example shown, the formula in C5 is:
=IF(B5="blue...