COUNTIF based on multiple criteria in Excel and Google Sheets

=SUMPRODUCT(COUNTIF(A:A,B:B))

A:A = Data ranges; B:B = criteria ranges

Check below for a detailed explanation with pictures and how to use formulas in Excel and Google Sheets.