The simplest way to solve this problem is with the COUNTIFS function.
COUNTIFS function
TheCOUNTIFS functionreturns the count of cells that meet one or more criteria.
COUNTIFS can be used with criteria based on dates, numbers, text, and other conditions.
COUNTIFS supportslogical operators(>,<,<>,=) andwildcards(*,?)
As the formula is copied down, it returns a count for each value in B5:B16.
Note this formula uses thefull column referenceB:B for convenience.
With two criteria
In the workbook below, we have Color and Price.
Notice these counts differ from the original example above because some of the same colors have different prices.
COUNTIF can be used to count cells that…